我的表格完整粘贴在下面,在 IE8 中没有验证。没有错误——验证只是被忽略了,所以人们可以提交任何东西。我正在使用 jquery 1.8.1 和验证插件版本 1.9。是语法问题吗?在 IE9、Chrome 或 Firefox 中没有问题。
粘贴下面的所有内容,因为我不知道问题出在哪里。
<!DOCTYPE HTML>
<html>
<head>
<!-- HTML5 biolerplace stuff below -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="">
<meta name="viewport" content="">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.6.1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script src="js/vendor/jquery.defaultvalue.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<style>
#formwrapper {
height:275px;
width:250px;
background-color: #f8f8f8;
border: 1px solid #cccccc;
padding: 25px 0 25px 25px;
font-family: arial;
font-size: 12px;
}
.entry {
border: 1px solid #cccccc;
margin: 5px 0;
width: 212px;
/* height: 26px; */
color: black;
padding: 7px 0 7px 10px;
}
#form_title, #button {
font-size: 18px;
}
#form_title {
color: #00589f;
margin-bottom: 20px;
}
#button {
width: 80px;
height: 24px;
position: relative;
left: 143px;
top: 15px;
background-color: #00589f;
border: none;
color: white !important;
}
.error {
border: 1px solid red;
background:#FFFFFF;
content: "text"
}
.empty {
color: #ccc;
}
</style>
<script type="text/javascript">
//form validation start
$(document).ready(function() {
//$('form').submit(function(){
// $('.incomplete').val('');
//});
//reject default values
$("#form").validate({
wrapper: ".formwrapper",
keyup: false,
//onfocusout: false,
//onclick: false,
//onchange: false,
errorLabelContainer: ".form",
//errorClass: "incomplete",
rules: {
organization: {
required: true,
minlength: 2
},
firstname: {
required: true,
minlength: 2
},
lastname: {
required: true,
minlength: 2
},
email: {
required: true,
email: true
},
phone: {
required: true,
minlength: 10,
digits: true
}
}
});
});
</script>
</head>
<body>
<div id="formwrapper">
<div id="form_title">REQUEST INFO</div>
<form id="form" name="form_container" action="#">
<!-- fields -->
<input class="entry" id="organization" type="text" name="organization" placeholder="Organization"/>
<input class="entry" id="firstname" type="text" name="firstname" placeholder="First Name"/>
<input class="entry" id="lastname" type="text" name="lastname" placeholder="Last Name"/>
<input class="entry" id="email" type="text" name="email" placeholder="Email"/>
<input class="entry" id="phone" type="text" name="phone" placeholder="Phone"/>
<!-- submit button -->
<input id="button" class="button" type="submit" value="Submit" />
</form>
</div>
<script>
//talks to defaultvalue plugin to make placeholders work in IE
$('#organization, #firstname, #lastname, #email, #phone').defaultValue();
</script>
</body>
</html>