Email form validation : Form Validation : Form Control : JavaScript DHTML examples (example source code) Organized by topic

JavaScript DHTML
C++
PHP
JavaScript DHTML Home »  Form Control   » [  Form Validation  ]   
 



Email form validation

Please note that some example is only working under IE or Firefox.

/*
Javascript Essentials
by Jason J. Manger

Publisher: Mcgraw-Hill Osborne Media; 

ISBN: 0078822343
*/

<!--
  Program 5-10
-->
<html>
<head>
<title>JavaScript E-mail-form interface</title>
<script language="JavaScript">
<!--
  function sendMail() {
    if (document.forms[0].recipient.value == "") {
       alert("No recipient has been specified!");
       return false;
    }
    if (document.forms[0].message.value == "") {
       alert("No message has been entered!");
       return false;
    }
    if (document.forms[0].subject.value == "") {
       document.forms[0].subject.value = "No subject";
       return false;
    }
    // Construct a mailto: URL with all the details:
    document.forms[0].action = "mailto:" +
                    document.forms[0].recipient.value +
                    "?subject=" +
                    document.forms[0].subject.value;
    return true;
  }
//-->
</script>
</head>
<body>
<basefont size=3>
<h2>E-mail form<hr></h2>
Please enter a recipient, optional subject, and the body of
your message,
and then press the <b>send mail</b> button.<p>
<form method="post" enctype="text/plain">
<table border=0>
<tr>
<td align="right"><b>To:</b></td>
<td><input type="text" name="recipient" size=60>
</td>
</tr>
<tr>
<td align="right"><b>Subject:</b></td>
<td><input type="text" name="subject" size=60></td>
</tr>
<tr valign="top">
<td align="right">
<img border=hspace=src="internal-gopher-text"></td>
<td><textarea name="message" rows=cols=60></textarea></td>
</tr>
</table>
<hr>
<input type="submit" value="Send mail" onClick="sendMail()">
</form>
</body>
</html>


           
       
Related examples in the same category
1.  Form Validator: time, date email, phone number, age etc
2.  Form Validate: is blank, is digit and is integer
3.  Log in form validation
4.  Log in email validation
5.  Comprehensive form validation
6.  Illegal sub string validation
7.  Form Validator
8.  Form valiation for empty data, file name
9.  Email Address Validate
10.  Time Validate
11.  URL Validate
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.