Reputation: 43
I have linked a form from campaign monitor to a mobile site and I am using jQuery validate for validation. All works well on desktop browsers but when I check on my Iphone the validations does not work.
I am not the experience using JQuery so any help would be much appreciated.
Thank you in advance!
Live Demo http://files.perfectday.gb.com/internal/stackoverflow/mobile-form/get-your-coupon.php
My validation JQuery and form are as follows.
<script type="text/javascript">
$.validator.methods.equal = function(value, element, param) {
return value == param;
};
$(document).ready(function(){
$("#subForm").validate({
rules: {
math: {
equal: <?php echo $randomNumTotal; ?>
}
},
messages: {
math: "Try again!!"
}
});
});
</script>
<!-- Form -->
<form action="http://perfectday.createsend.com/t/j/s/nyuyh/" method="post" id="subForm">
<div class="name">
<label for="name">Name:<span>*</span></label><br>
<input type="text" name="cm-name" id="name" size="25" class="required text-input" />
</div>
<div class="nyuyh-nyuyh">
<label for="nyuyh-nyuyh">Email Address:<span>*</span></label><br>
<input type="text" name="cm-nyuyh-nyuyh" id="nyuyh-nyuyh" size="25" class="required email text-input"/>
</div>
<div class="address1">
<label for="Address 1">Address 1:<span>*</span></label><br>
<input type="text" name="cm-f-juar" id="Address1" size="25" class="required text-input" />
</div>
<div class="address2">
<label for="Address 2">Address 2:<span>*</span></label><br>
<input type="text" name="cm-f-juaj" id="Address2" size="25" class="text-input required" />
</div>
<div class="city">
<label for="City">City/town:<span>*</span></label><br>
<input type="text" name="cm-f-juat" id="City" size="25"class="required text-input" />
</div>
<div class="postal">
<label for="postal">Post code:<span>*</span></label><br>
<input type="text" name="cm-f-juai" id="postal" size="25"class="required text-input" />
</div>
<div class="captcha">
Enter the correct result<span>*</span><br>
<input type="text" name="captchaImage" id="sum" value="<?php echo $randomNum ?> + <?php echo $randomNum2 ?>" disabled="disabled" />
<input type="text" name="math" id="math" maxlength="6" />
</div>
<input value="submit information" class="submit" type="image" src="images/trans.png" class="get-your-coupon-submit" alt="Submit" >
<br>
</form>
Upvotes: 1
Views: 7788
Reputation: 9347
(3 year later update): I've also found issues with with iPhones and jQuery.validate. Although the validation was applying, the first field was not scrolling into view. To get around this, I just updated my .invalidHandler()
method to include:
$("foo").validate({
invalidHandler: function(e, validator) {
if(window.navigator.userAgent.match(/iphone/i)) {
window.setTimeout(function() {
$("html,body").animate({
scrollTop: $(validator.errorList[0].element).offset().top
});
}, 0);
}
}
});
Upvotes: 2
Reputation: 46
I had the same issue on the iPhone with jQuery version 1.6.1+ and Validations plugin version 1.9
The workaround was to configure the plugin to not validate on form submit:
$("form").validate({
onsubmit: false
});
Validate the form and submit programmatically:
if( $("form").valid() ){
// post validation code
form.submit()
}
Upvotes: 3