How to taget a specific form using javascript

can anyone help me with the below:

Here is my javaScript:

<script type="text/javascript">
    $(function () {

        $('#first_name, #second_name, #third_name, #fourth_name').bind("change keyup",
  function () {      
      if ($("#first_name").val() && $("#second_name").val() != "" && $("#third_name").val() != "" && $("#fourth_name").val() != "")
          $(this).closest("form").find(":submit").attr("disabled", "disabled");      

And here is my HTML:

<form method="post" id="myForm" name="myForm">
     <div id="terms_area">
                    <label>Print your name</label>
                    <input id="first_name" type="text" />    

                    <label>Print your surname</label>
                    <input id="second_name" type="text" />    

                    <label>Print your surname</label>
                    <input id="third_name" type="text" />    

                    <label>Print your surname</label>
                    <input id="fourth_name" type="text" />    
                <input class="terms_button" type="submit" value="I accept the terms of this agreement" disabled title="please fill in all required fields to accept the terms" />

Is there any way I can get the JavaScript to target the form name of ‘myForm’ as I have multiple forms on one page.



Source: jquery

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.