Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

javascript help eek !

Options
  • 27-03-2002 9:04pm
    #1
    Registered Users Posts: 476 ✭✭


    the stuff in the HEAD
    <script language="JavaScript">
    <!--
    re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
    function ValidationCheck() {
    	if ((CvFORM.cvEmail.value)!=re.test){
    	alert("invalid e-mail address, 
     		you must enter a valid address such as your [email]name@yourisp.com[/email]");	
    	return false;
            }
    
    return true;
    }
    //-->
    </script>
    

    the stuff in the BODY
    <FORM action="" METHOD="post" NAME="CvFORM" onSubmit="return ValidationCheck()">
      <table border NAME="cvtable">
       <tr> 
        <td CLASS="intro">
    Your E-mail address :     </td>
         <td CLASS="details">
          <input type="text" name="cvEmail" size="35"></INPUT>
         </td>
        </tr>
    </TABLE>
    </FORM>
    


    now how come this won't work for me . i want it to display an alert box if there the re part isn't happy.


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    now how come this won't work for me .

    Define "won't work" Pablo.

    i want it to display an alert box if there the re part isn't happy.

    The alert() should be all on one line anyway.

    adam


  • Registered Users Posts: 476 ✭✭Pablo


    i want it to return "false" if a user fails to enter an email address that its valid. as in the re.test is false for the object CvFORM.cvEmail.value .


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    <html>
    <head>
    <title>Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    <!--
    re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
    function ValidationCheck() {
    	if (!re.test(CvFORM.cvEmail.value)){
    		alert("invalid e-mail address, you must enter a valid address such as your [email]name@yourisp.com[/email]");
    		return false;
    	}
    	return true;
    }
    //-->
    </script>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <form action="test.htm" method="post" name="CvFORM" onSubmit="return ValidationCheck()">
     <table border name="cvtable">
      <tr> 
       <td class="intro"> Your E-mail address: </td>
       <td class="details">
        <input type="text" name="cvEmail" size="35">
       </td>
       <td class="details">
        <input type="submit" name="Submit" value="Submit">
       </td>
      </tr>
     </table>
    </form>
    </body>
    </html>
    

    Howzat?

    adam


  • Registered Users Posts: 476 ✭✭Pablo


    Originally posted by dahamsta
    Howzat?

    adam
    working :D

    merci .

    i wasn't sure about where the bash would go, but thats excellent , and isn't it bad the way that it seems obvious now :rolleyes:

    thanks adam


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Pleasure.

    adam


  • Advertisement
Advertisement