Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Validation resetForm() function not working
    primarykey
    data
    text
    <p>Ok I have a form that has Yes and No radio buttons. When the user clicks either, it fires a radioChanged() function which checks to see which box is checked. If no is checked, it shows email fields and validates the form based on the rules. If the user clicks back on "Yes" i need the validations to reset and clear but it doesn't appear to be working. Should I just do a new validation if yes is checked that does not require the email fields?</p> <pre><code>&lt;script type="text/javascript"&gt; var validator = $("#newClient"); function radioChange() { if (document.getElementById("yesbutton").checked == true) { document.getElementById("emailSpan").style.display = "none"; document.getElementById("cemailSpan").style.display = "none"; document.getElementById("emailError").style.display = "none"; document.getElementById("cemailError").style.display = "none"; validator.resetForm(); } else if (document.getElementById("nobutton").checked == true) { document.getElementById("emailSpan").style.display = 'block'; document.getElementById("cemailSpan").style.display = 'block'; document.getElementById("emailError").style.display = "block"; document.getElementById("cemailError").style.display = "block"; validator.validate({ rules: { Email: { required: true, minlength: 4, maxlength: 48, email: true }, ConfirmEmail: { required: true, minlength: 4, maxlength: 48, email: true, equalTo: "#Email" } }, messages: { Email: { required: "Please enter a valid email address", email: "Please enter a valid email address", maxlength: "Max length is 48" }, ConfirmEmail: { required: "Please enter a valid email address", email: "Please enter a valid email address", maxlength: "Max length is 48", equalTo: "Emails do not match" } }, errorPlacement: function(error, element) { if (element.attr("name") == "ConfirmEmail") error.appendTo("#cemailError"); else if (element.attr("name") == "Email") error.appendTo("#emailError"); } }) } } &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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