嗨,我在我的應用程序中使用jQuery驗證插件和jQuery。驗證工作在Firefox
,但不在任何IE
版本中工作。我不知道爲什麼。請幫助jquery驗證不工作ie9,ie8,ie7,ie6
<html>
<head>
<script type="text/javascript" src="<?php echo $this->config->item('3rd'); ?>jquery/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="<?php echo $this->config->item('3rd'); ?>jquery/jquery.validate.js"></script>
<script>
var jq = jQuery.noConflict();
jq(document).ready(function(){
var x=jq("#test").validate({
rules: {
fname: {
required:true,
minlength: 3,
maxlength: 250
},
lname: {
required:true,
minlength: 3,
maxlength: 250
}
},
messages: {
fname: {
required: "Enter your Business Name",
minlength: "At least 3 characters long",
maxlength:"Maximum length allowed is 250 charactors"
},
lname: {
required: "Enter City",
minlength: "min length 3",
maxlength:"Max length 250"
}
}
});
});
</script>
</head>
<body>
<form action="" method="post" id="test">
First name: <input type="text" name="fname" /><br />
Last name: <input type="text" name="lname" /><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
它給出了什麼錯誤? – diEcho
沒有給出錯誤,只是提交表單,它忽略了驗證 –
你還沒有在兩個輸入字段中加入'class =「required」'。試試這個。並且爲這兩個輸入設置'id' – diEcho