www.webdeveloper.com
Results 1 to 2 of 2

Thread: validation issue

Hybrid View

  1. #1
    Join Date
    Nov 2011
    Posts
    64

    validation issue

    Code:
    <script>
    function validateForm()
    {
    var x=document.forms["myForm"]["name"].value;
    if (x==null || x=="")
      {
      alert("First name must be filled out");
      return false;
      }
    }
    </script>
    
    <form name="myForm" action="<?php print $PHP_SELF ?>" onsubmit="return validateForm()" method="post">
    Input name : <input type="text" name="name"><br><br>
    <input type="submit" name="students" value="addnow">
    The above code is working fine. If i added another form. The code might looks like below.


    Code:
    <form name="form" action="<?php print $PHP_SELF ?>" method="post">
    <input type="text" name="time">
    <input type="submit" name="date" value="insert">
    
    
    <script>
    function validateForm()
    {
    var x=document.forms["myForm"]["name"].value;
    if (x==null || x=="")
      {
      alert("First name must be filled out");
      return false;
      }
    }
    </script>
    
    
    
    <form name="myForm" action="<?php print $PHP_SELF ?>" onsubmit="return validateForm()" method="post">
    Input name : <input type="text" name="name"><br><br>
    <input type="submit" name="students" value="addnow">
    It is not working for the validation. Can anyone pls help ?

  2. #2
    Join Date
    Nov 2011
    Posts
    64
    Thk i think i got the answer.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles