Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try adding a submit handler to the form:</p> <pre><code>onClick='return frmSubmit()' </code></pre> <p>In this handler, you first serialize the form's data, and submit this to the validation script. Be sure to <code>return false</code> after issuing the request, as it is done asynchronously. In the response callback, you implement the following: if the response indicates that the input is valid, you programatically submit the form with the <code>.submit()</code>-method. If, however, the reponse indicates that something's wrong (you'll have to supply the feedback in JSON-format), attach some constructive feedback to the form for the user to read.</p> <p>Don't forget to catch the keypress event, and prevent the form from being submitted when Enter is pressed, as it will bypass your validation function.</p> <p>And, uhm, one suggestion: it might be better to do all the validation on the client-side to start with, which is usually enough. You probably heard that client-side validation can be circumvented, so there is still a need for server-side checking. However, I always feel that if a user decides to mess with the system seriously, then it isn't necessary to provide constructive feedback. A simple message indicating failure will suffice. So, first check the input with plain Javascript. If something's wrong, provide feedback. If, however, the server receives invalid input (which means that the client-side validation has been bypassed), just notify the user that he failed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload