Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In response to the original jsfiddle, please see this version:</p> <p><a href="http://jsfiddle.net/33PGQ/23/" rel="noreferrer">http://jsfiddle.net/33PGQ/23/</a></p> <p>This is modified in three ways: firstly, at the bottom, a simple boolean value is set to equal whether both fields are valid (it's then alerted). As each valid() call returns a boolean value, you can simply and easily check the validity of all form elements.</p> <p>Secondly, the validate option is expanded with a custom showErrors function that has no internal code. This function overrides the default behaviour for the validation errors, so that while the internal validity of the fields can be checked and the validity of the fields is handled, no actual error text is displayed, thereby enabling all the validation rules but eliminating the display of the validation results.</p> <p>Lastly, though it isn't explicitly requested in the initial question, I added the optional "onsubmit:false" setting, which overrides the validate call's default behaviour of preventing form submission unless all validation rules are successfully checked. This can be removed if you want to prevent submission (I assume you would), but I think it's a useful feature to be aware of. I included it here in case you had a special case where you would want the form to submit even if the form's validation had failed.</p> <p>It's definitely worth reviewing the options list for validate; there are many ways you can adjust the validator's behaviour to suit exactly what you want.</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