SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2002
    Location
    vancouver, bc
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation need help with my simple form validation script...

    Hi,

    I'm trying to write my own form validation script, and I'm starting out on very very simple beginnings but i'm having problems already!

    here's my script:

    PHP Code:
       <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
     
     <
    html>
     <
    head>
     <
    title>Page title</title>
     </
    head>
     <
    body>
     
     <
    script language="JavaScript" type="text/javascript">
     <!--
     
     function 
    checkName(string) {
         var 
    nameError ="";
       if (
    string == "") {
           
    nameError "Please enter your name in the required field\n";
       }
     }
     
     function 
    checkNote(string) {
         var 
    noteError ="";
       if (
    string == "") {
           
    noteError "Please enter a valid email address in the required field\n";
       }
     }
     
     
    /*
     function checkPhone(string) {
         var phoneError ="";
       if (string == "") {
           phoneError = "Please enter your contact telephone number\n";
       }
     }
     */
     
     
    function checkForm(testForm) {
         var 
    errorMsg "";
       
       
    checkName(testForm.name.value);
       
    checkNote(testForm.note.value);
         
       
    errorMsg nameError noteError;   
           if (
    errorMsg != "") {
            
    alert(errorMsg);
            return 
    false;
         }
     return 
    true;
     }
     
    //-->
     
    </script>
     
     
     <form name="testForm" action="test2.php" method="POST">
      
     name: <input type="text" name="name" value="">
      
     note: <input type="text" name="note" value="">
      
     <br>
     
     <br>
     
     <button type="button" onclick="checkForm(testForm);">Submit</button>
     
     </form>
     </body>
     </html> 
    thanks,
    edwinx

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2002
    Location
    vancouver, bc
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone give me some pointers, i suck at javascript and so far. i'm stuck on this.


Bookmarks

Posting Permissions

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