Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

javascript help eek !

  • 27-03-2002 09:04PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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