Reputation: 706
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>
Upvotes: 1
Views: 73
Reputation: 102793
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
});
Upvotes: 0
Reputation: 87073
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
Upvotes: 1
Reputation: 123428
try to pass you callback without ()
$("#contact_email").validate(screenCheck);
Please also note that your function is called screenCheck
and not screenCkeck
Upvotes: 3