jQuery 验证无法在 iPhone 上运行
我已将活动监视器中的表单链接到移动网站,并使用 jQuery validate 进行验证。 一切在桌面浏览器上运行良好,但当我在 Iphone 上检查时,验证不起作用。
我没有使用 JQuery 的经验,所以任何帮助将不胜感激。
先感谢您!
现场演示 http://files.perfectday.gb.com /internal/stackoverflow/mobile-form/get-your-coupon.php
我的验证JQuery和表单如下。
<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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在使用 jQuery 版本 1.6.1+ 和验证插件版本 1.9 的 iPhone 上遇到了同样的问题
解决方法是将插件配置为不在表单提交时进行验证:
验证表单并以编程方式提交:
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:
Validate the form and submit programmatically:
(3 年后更新):我还发现了 iPhone 和 jQuery.validate 的问题。尽管正在应用验证,但第一个字段并未滚动到视图中。为了解决这个问题,我刚刚更新了我的
.invalidHandler()
方法以包括:(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: