0

Is there a way to remove/disable WordPress default registration client side validation? I dislike the pop alert and would like to add my own client side validation visual to users.

Please assist me and thank you.

Update

(function($) {

window.onload = function() {
    var form = document.getElementById('s2member-pro-paypal-registration-form');
    form.onsubmit = function() {
        cValidate();
    }
}

function cValidate() {
    var valid = true;
    var content = document.getElementById('form-errors');
    var msg = "Please correct the following errors: <br />";

    var elements = [
        document.getElementById('s2member-pro-paypal-registration-first-name'),
        document.getElementById('s2member-pro-paypal-registration-last-name'),
        document.getElementById('s2member-pro-paypal-registration-email'),
        document.getElementById('s2member-pro-paypal-registration-username'),
        document.getElementById('s2member-pro-paypal-registration-password1'),
        document.getElementById('s2member-pro-paypal-registration-password2'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-salutation-id'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-job-title'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-functional-role'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-department-field'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-direct-phone'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-company-name'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-street-address'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-city-id'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-zcode-id'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-state-id'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-country-id'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-industry-id'),
        document.getElementById('s2member-pro-paypal-registration-custom-reg-field-company-website'),
        document.getElementById('recaptcha_response_field')
    ];

    if (elements[0].value == "") {
        msg += "First name field is empty.  <br />";
        content.innerHTML = msg;
    }
    if (elements[1].value == "") {
        msg += "Last name field is empty.  <br />";
        content.innerHTML = msg;
    }
    if (elements[2].value == "") {
        msg += "Email field is empty.  <br />";
        content.innerHTML = msg;
    }
    if (elements[3].value == "") {
        msg += "Username field is empty.  <br />";
        content.innerHTML = msg;
    }
    if (elements[4].value == "") {
        msg += "Password name field is empty.  <br />";
        content.innerHTML = msg;
    }
    if (elements[5].value == "") {
        msg += "Re-enter Password field field is empty.  <br />";
        content.innerHTML = msg;
    }

}

})(jQuery);
  • So far, I tried adding my own custom javascript validation and it seems to be overriding it but I'm not sure if that's the safe way to approach. I've also tried using window.alert = function(){}; but the submit button stops working. – rolu Jan 16 '14 at 15:56
  • Edit the relevant code into the question please. – s_ha_dum Jan 16 '14 at 15:57
  • I tried validating the registration form with my own custom client side validation and it overwrites the WordPress validation. Is that suppose to happen and will I encounter errors in the long run? – rolu Jan 16 '14 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.