2017-01-16 10 views
0

名前、姓、金額、個人ID、コメントを入力するフォームがあります。 iは値が20submitでjクエリを使用してカスタムフォーム検証を作成する方法

より低く傾くように、これはiが20未満である量を防止するために必要と私は複数を回避する必要があるフォーム

<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> 

が提出され、フィールド量ことを検証する必要が ユーザーのクリックを送信する、これまでのところ、私は今、私は今、私はそれを検証する必要があり、Javaスクリプトで検証したが、何らかの理由でフィールドを検証していましたが、複数の送信を避けていなかったので、jqueryですべてをコーディングしたいと思います。

答えて

0

それは誰でも助けてほしい、私はそれを私の自己を使って解決しましたifステートメントを使用して、量フィールドを検証し、20未満の量を入力し、複数の送信を避ける

関連する問題