Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

re: Validate email address

Hi all!

I have the following form, and would like to validate the phone and email address before it's submitted - so the email addresses are the same in both entries, etc.  I've tried a few tricks, but can't get it working. Any tips?

Thanks in advance


<form name="form" method="post" action="http://www.narcissusdesign/cgi-bin/cgiemail/email.txt">
              <table width="100%" border="0" cellpadding="2" cellspacing="2" class="fonts">
                  <td width="23%">Firstname:</td>
                  <td width="77%"><input name="firstname" value=" " type="text" size="45"></td>
                  <td><input name="lastname" value=" " type="text" size="45"></td>
                  <td><input name="email" value=" " type="text" size="45"></td>
                  <td>Verify Email:</td>
                  <td><input name="verifyemail" type="text" id="verifyemail" value=" " size="45"></td>
                  <td>Phone Number:</td>
                  <td><input name="phone" value=" " type="text" size="45"></td>
                  <td>Verify Phone Number:</td>
                  <td><input name="verifyphone" type="text" id="verifyphone" size="45"></td>
                  <td>Preferred Contact Mode:</td>
                  <td><input name="preferemail" type="checkbox" id="preferemail" value="checkbox">
                    <input name="preferphone"type="checkbox" id="preferphone" value="checkbox">
                    Phone </td>
                  <td><input name="subject" type="text" id="subject" size="45"></td>
                  <td align="left" valign="top">Question/Comment:</td>
                  <td><textarea name="comment" value="comment" cols="50" rows="10"></textarea></td>
                  <td><br> <input type="reset" name="reset" value="Reset Form">
                    &nbsp;&nbsp; <input type="submit" name="submit" value="Submit Email">
                    <br> <INPUT TYPE="hidden" NAME="addendum" VALUE="http://www.narcissusdesign.com.au/thankyou.htm">
1 Solution
Hi angmine,

Here's a simple example for ensuring that both the phone and the verifyphone text fields are the same:

<FORM onSubmit="return validate(this)">
<INPUT TYPE="text" id="phone"><br>
<INPUT TYPE="text" id="verifyphone"><Br>
<INPUT TYPE="submit">

<script language="JavaScript" type="text/javascript">
function validate(Form) {
    if (Form.phone.value != Form.verifyphone.value)
        alert("phones not identical");
        return false;

- Maddog

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now