-
Notifications
You must be signed in to change notification settings - Fork 508
Required fields in rails.js
neerajdotname edited this page Jan 24, 2013
·
1 revision
If any blank required inputs (required="required") are detected in the remote form, the whole form submission is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
The ajax:aborted:required
event allows you to bind your own handler to inform the user of blank required inputs.
Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
$('form').bind('ajax:aborted:required', function(event, elements){
// Returning false in this handler tells rails.js to submit the form anyway.
// The blank required inputs are passed to this function in `elements`.
return ! confirm("Would you like to submit the form with missing info?");
});