1

I want that screenCheck function show run only after Validation of #contact_email. But in my case its running before that. how do I correct it?

<script>
function screenCheck() {
    var screenWidth = window.screen.width;
    if (screenWidth == '1024') {
        $('#textAreaMsg label.error').css('margin-left', '99px');
    }
}

$(document).ready(function() {
    $("#contact_email").validate(screenCkeck());​
</script>

3 Answers 3

3

try to pass you callback without ()

$("#contact_email").validate(screenCheck);

Please also note that your function is called screenCheck and not screenCkeck

Sign up to request clarification or add additional context in comments.

1 Comment

did you Check/Ckeck the function name ? If it's still not working please specify which plugin you're using (so I can see the code)
1

Beside @F. Calderan mentionded, I think your

$(document).ready(function() {
 $("#contact_email").validate(screenCkeck());​

need a closing )}; like

$(document).ready(function() {
 $("#contact_email").validate(screenCheck);​
}); // need closing

Comments

0

Assuming you're using the JQuery validator plugin, you need to pass the callback as part of the options map. For example, to make your callback run after the form has been deemed invalid, you'd write it like this:

$("#contact_email").validate({
    invalidHandler: screenCheck
});

The same goes for the submitHandler and/or the showErrors handler. To handle all three, you'd write it like this:

$("#contact_email").validate({
    invalidHandler: screenCheck,
    submitHandler: submitCallback,
    showErrors: showErrorsCallback
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.