假设我有一个文本输入字段,我想确保当输入字段在某些日期收到某些文本时,用户只能按提交按钮/浏览表单....
是否可以使用jquery验证插件
我已经设置了一个js小提琴http://jsfiddle.net/ecj6J/3/
<div class="container">
<div class="clearfix"></div>
<form class="form-horizontal" role="form" name="submitDetails" action="#" method="POST" id="submitDetails">
<div class="form-group col-xs-12">
<label class="col-xs-5 control-label" for="firstName">First Name</label>
<div class="col-xs-7">
<input id="firstName" name="firstName" type="text" class="form-control input-md" maxlength="80"/>
</div>
</div>
<div class="clearfix"></div>
<div class="form-group col-xs-12 mySubmitButton">
<div class="col-xs-12">
<button id="submit" name="submit" class="btn btn-primary center-block" title="SUBMIT" type="submit">SUBMIT</button>
</div>
</div>
</form>
到目前为止js验证码
$(document).ready(function () {
$('#submitDetails').validate({
// 1. validation rules.
rules: {
firstName: {
required: true,
}
},
messages: {
firstName: "Please enter your first name"
});
///execute when submit button is clicked
$("#submit").click(function () {
});
});
所以基本上,当用户在第1天按下文本“ABCD”时,他被允许处理,否则将显示错误消息。类似地,当用户在第2天输入文本“EFGH”时,他被允许处理,否则他将显示错误字段文本消息。