好的,我已经在 JSFiddle 中重现了这个问题。以下形式适用于 Chrome 和 IE9,但不适用于 IE7 或 IE8。我发现一些关于 jQuery 特定版本的传言;我们使用的是 1.4.4。这是小提琴的链接:
表格
<form action="" id="step1Form" method="post">
<label for="FirstName">FirstName</label>
<input class="text-box single-line" data-val="true" data-val-required="The FirstName field is required." id="FirstName" name="FirstName" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="FirstName" data-valmsg-replace="true"></span>
<br/>
<label for="LastName">LastName</label>
<input class="text-box single-line" data-val="true" data-val-length="The field LastName must be a string with a maximum length of 60." data-val-length-max="60" data-val-required="The LastName field is required." id="LastName" name="LastName" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="LastName" data-valmsg-replace="true"></span>
<br />
<label for="Age">Age</label>
<input class="text-box single-line" data-val="true" data-val-number="The field Age must be a number." data-val-range="The field Age must be between 1 and 130." data-val-range-max="130" data-val-range-min="1" data-val-required="The Age field is required." id="Age" name="Age" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="Age" data-valmsg-replace="true"></span>
<br/>
<input type="submit" value="Submit"/>
</form>
Javascript
$(function(){
$('#step1Form').live('submit',function(e){
e.preventDefault();
console.log('sup');
//do an ajax request here or something!
});
});