我在使用模式显示登录框(bootstrap-modal.js)的页面上使用 twitter bootstrap css 框架。在登录框中,我使用 jquery 非常简单的验证 (jquery.rsv.js) 来验证电子邮件 ID 和密码。问题是验证在 IE 9 的登录模式框中不起作用。在同一页面上,我有另一个不在模式中的表单,并且验证工作得很好。
以下是我的引导模式表单代码:-
<div id="modal-from-login" class="modal hide fade">
<div class="modal-header">
<a href="#" class="close">×</a>
<h3>Login for existing customers</h3>
</div>
<div class="modal-body">
<form id="loginform" name="loginform" method="post" action="login/">
<div class="clearfix"><label for="comments">Email ID:</label>
<input type="text" name="email" id="loginemail" /></div>
<div class="clearfix"><label for="comments">Password:</label>
<input type="password" name="password" id="loginpassword" />
</div>
</div>
<div class="modal-footer">
<input type="submit" style="float:left;margin-left:130px;" name="login" id="login" value="Login" class="btn primary" />
</div>
</form>
</div>
这是按钮代码:-
<button class="btn primary" data-controls-modal="modal-from-login" data-backdrop="true" data-keyboard="true" style="margin-top:5px;">Login</button>
用于验证的 javascript 代码:-
function my_custom_function()
{
if (document.getElementById("website").value){
var url = document.getElementById("website").value;
var test = /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url);
var field = document.getElementById("website");
if(test){
return true;
}else{
return [[field, "Please enter a valid website."]];
}
}else{
return true;
}
}
$(document).ready(function() {
function loginComplete(){
return true;
}
$("#loginform").RSV({
onCompleteHandler: loginComplete,
rules: [
"required,loginemail,Please enter your email id.",
"valid_email,loginemail,Please enter a valid email address.",
"required,loginpassword,Please enter your password."
]
});
});
</script>
我正在使用 jquery 1.4.2
问题是什么??即使在 IE8 中,此代码在所有其他浏览器中也能正常工作,问题仅在 IE 9 中存在。