July 2011
Intermediate to advanced
276 pages
5h 11m
English
Launching off the last extension, the forms on our site may also need to ask for confirmation. It is not unthinkable that a slip of the carriage return could accidentally submit a form before a user is ready. It certainly happens to all of us occasionally and perhaps to some of us regularly.
Mutate the HTML DOM FORM elements to act upon the onSubmit event and prompt whether to continue with the submission.
Element.implement({
polite_forms: function() {
if (this.get('tag')=='form') {
this.addEvent('submit',function(e) {
if(!confirm('Okay to submit form?')) {
e.stop();
}
});
}
}
});
The polite_forms() method is added to all HTML DOM elements, but the execution is restricted ...