Reputation: 6660
I have a form that I'm submitting with AJAX. A user fills out the field (called "barcode") and hits return, and the form submits.
After the form submits, they are shown a success or failure message. I want to:
So far I have got step 1 handled:
setTimeout(function(){ $('span.login-fail').parent().fadeOut('normal'); }, 1000);
setTimeout(function(){ $('span.login-welcome').parent().fadeOut('normal'); }, 1000);
But I do not know how to do 2 or 3. Thanks for any help!
Upvotes: 0
Views: 3416
Reputation: 41232
You can do:
$( "#form_id").find( "input").val( "").end( ).find( "input:first").focus();
this will clean all inputs in the form and move focus to the first one in the list.
Upvotes: 0
Reputation: 2305
To clear a field just use $("#fieldID").val("")
which will set the value to nothing.
Focus is done just by using the focus method $("#fieldID").focus()
Upvotes: 2