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

x
  • 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">
                <tr>
                  <td width="23%">Firstname:</td>
                  <td width="77%"><input name="firstname" value=" " type="text" size="45"></td>
                </tr>
                <tr>
                  <td>Lastname:</td>
                  <td><input name="lastname" value=" " type="text" size="45"></td>
                </tr>
                <tr>
                  <td>Email:</td>
                  <td><input name="email" value=" " type="text" size="45"></td>
                </tr>
                <tr>
                  <td>Verify Email:</td>
                  <td><input name="verifyemail" type="text" id="verifyemail" value=" " size="45"></td>
                </tr>
                <tr>
                  <td>Phone Number:</td>
                  <td><input name="phone" value=" " type="text" size="45"></td>
                </tr>
                <tr>
                  <td>Verify Phone Number:</td>
                  <td><input name="verifyphone" type="text" id="verifyphone" size="45"></td>
                </tr>
                <tr>
                  <td>Preferred Contact Mode:</td>
                  <td><input name="preferemail" type="checkbox" id="preferemail" value="checkbox">
                    Email
                    <input name="preferphone"type="checkbox" id="preferphone" value="checkbox">
                    Phone </td>
                </tr>
                <tr>
                  <td>Subject:</td>
                  <td><input name="subject" type="text" id="subject" size="45"></td>
                </tr>
                <tr>
                  <td align="left" valign="top">Question/Comment:</td>
                  <td><textarea name="comment" value="comment" cols="50" rows="10"></textarea></td>
                </tr>
                <tr>
                  <td>&nbsp;</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">
                  </td>
                </tr>
              </table>
            </form>
0
angmine
Asked:
angmine
1 Solution
 
_Maddog_Commented:
Hi angmine,

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

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

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

- Maddog
0

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