0
我有一个表单输入名称,姓氏,金额,个人ID,评论。 我需要验证该字段量,因此该值不能低于20如何使用j查询创建自定义表单验证提交
这是形式
<form name="myForm"class="form-signup" id ="req-form" action="reg_form.php" method="post">
<div class="form-group">
<label for="fname">First Name:</label><span style="color:red;" id="ferror"> </span>
<input class="form-control" type="text" name="fname" id="fname" value="<?php echo "$user_fname";?>">
<label for="lname">Last Name:</label><span style="color:red;" id="lerror"> </span>
<input class="form-control" type="text" name="lname" id="lname" value="<?php echo "$user_lname";?>">
<label for="amount">Amount:</label><span style="color:red;" id="aerror"> </span>
<input class="form-control" type="text" name="amount" required id="amount" placeholder="Amount">
<label for="cedula">personal id:</label><span style="color:red;" id="cferror"> </span>
<input class="form-control" type="text" name="cedula" id="cedula" value="<?php echo "$user_cedula";?>">
<label for="cedula">comments:</label><span style="color:red;" id="coferror"> </span>
<input class="form-control" type="text" name="comments" id="comments" placeholder="comments optional">
<input class="btn btn-warning" type="submit" value="Submit" name="myButton" >
</div>
</form>
<script>
$(document).ready(function(e){
$('#req-form').on('submit',function(){
alert($('#amount').val());
});
});
$('#req-form').submit(function(){
$this = $(this);
/** prevent double posting */
if ($this.data().isSubmitted) {
return false;
}
/** do some processing */
/** mark the form as processed, so we will not process it again */
$this.data().isSubmitted = true;
return true;
});
</script>
我需要防止量小于20,我需要避免多次提交时用户点击提交,到目前为止我得到它的工作,我现在需要做的是避免金额小于20,到目前为止验证我得到它提醒现在我需要验证的数量,没有验证与Java脚本,但为某些原因它验证字段,但没有避免多次提交,所以我想用jquery编码所有内容