Clear input on focus
Clear input on focus
I need to clear an inline table input field on focus and replace default value if on blur is blank.
I tried a JQuery script in my document.ready function which I have used in other web forms which works.
I can not get this to work in DataTable Editor . It looked everywhere for an alternate solution but came up empty.
Any insight is welcomed.
var default_value = '' //Global var
$('#DTE_Field_HRWPER').focus(function(){
default_value = this.value
this.value = '';
});
$('#DTE_Field_HRWPER').blur(function(){
if (!this.value.length) {
this.value = default_value;
}
});
This discussion has been closed.
Replies
Use the
initSubmit
event. There you can check if a field's value is empty and if so set it to be a different value.Allan
That seems like a good event, but maybe not for my intended purpose. I need a onFocus like event.
When a user tabs to or mouse clicks into a inline field that already contains data, I need save the data in a temp variable and set the field to blank. If the user leaves the field (other then submit) without entering any new data, then set it back to the original value found in the temp variable.
It appears the initSubmit can not achieve this.
can be used.
field().input()
will give you the jQuery object for theinput
element.Allan
Looks like that is what I needed. Here is the working script. Thank you!