我正在使用 jquery-validate 结合 twitter 引导程序在页面上进行一些简单的表单验证。
在 Chrome 上,它可以完美运行,没有任何延迟,但在 FireFox 上却存在可怕的延迟,文本出现的时间远远晚于按键。除此之外,它工作正常。
这是我的代码,我做错了吗?
<form class="form-horizontal" id="enrolform" method="post">
<fieldset>
<legend>Enrolment Form <small>* required fields</small></legend>
<div class="control-group" >
<label class="control-label" for="invite">Invite Code *</label>
<div class="controls">
<input type="text" class="input-xlarge" name="invite" id="invite">
</div>
</div>
<div class="control-group">
<label class="control-label" for="first">First Name *</label>
<div class="controls">
<input type="text" class="input-xlarge" name="first" id="first" value="{{ first }}" >
</div>
</div>
<div class="control-group">
<label class="control-label" for="last">Last Name *</label>
<div class="controls">
<input type="text" class="input-xlarge" name="last" id="last" value="{{ last }}">
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">Email Address *</label>
<div class="controls">
<input type="text" class="input-xlarge" name="email" id="email" value="{{ email }}" >
</div>
</div>
<div class="control-group">
<label class="control-label" for="phone">Phone Number</label>
<div class="controls">
<input type="text" class="input-xlarge" name="phone" id="phone" class="required" value="{{ phone }}" >
</div>
</div>
<div class="control-group">
<label class="control-label" for="mobile">Mobile Number</label>
<div class="controls">
<input type="text" class="input-xlarge" name="mobile" id="mobile" value="{{ mobile }}" >
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary btn-large"\">Enrol</button>
</div>
</fieldset>
</form>
<script>
$(document).ready(function(){
var validator = $('#enrolform').validate(
{
rules: {
invite: {
minlength: 2,
required: true
},
email: {
required: true,
email: true
},
first: {
required: true
},
last: {
required: true
},
phone: {
digits: true
},
mobile: {
digits: true
}
},
highlight: function(label) {
$(label).closest('.control-group').addClass('error');
},
success: function(label) {
label
.text('OK!').addClass('valid')
.closest('.control-group').addClass('success');
}
});
</script>