This site provides users with the information about html: email form validation, how to validate email form, javascript email form validation, how to validate email address, clear form, example, and more.
If you think that this site is helpful, please recommend your friends to visit our site.
How to validate email form using javascript?
For validating email form, you need to add a little javascript code. The following is an example for how to validate email form using javascript in html.
--------------------------------------------------------------------------------
< SCRIPT LANGUAGE="JavaScript">
function fixProblem(element, message) {
alert(message);
element.focus();
}
function checkValidation(form) {
var passed = false;
if (form.fullname.value == "") {
fixProblem(form.fullname, "Please enter your name.");
}
else if (form.email.value.indexOf("@") == -1 ||
form.email.value.indexOf(".") == -1) {
fixProblem(form.email, "Email address invalid!");
}
else if (form.message.value == "") {
fixProblem(form.message, "Please enter a message.");
}
else {
passed = true;
}
return passed;
}
< /SCRIPT>
< FORM NAME = "mail" ACTION = "mailto:yourname@gmail.com"
METHOD = "POST" ENCTYPE = "text/plain"
onSubmit = "return checkValidation (this);">
< TABLE BORDER = 0 CELLPADDING = 5 CELLSPACING = 0>
< TR>
< TD>
Your Full Name:
< P>
< INPUT TYPE = "TEXT" NAME = "fullname" >
< /TD>
< TD>
Your Email Address:
< P>
< INPUT TYPE = "TEXT" NAME = "email" >
< /TD>
< /TR>
< TR>
< TD COLSPAN = "2">
Enter your Message:
< P>
< TEXTAREA ROWS = "8" COLS = "38" NAME = "message">
< /TEXTAREA>
< /TD>
< /TR>
< TR>
< TD COLSPAN = "2">
< INPUT TYPE = "SUBMIT" VALUE = "Submit">
< INPUT TYPE = "RESET" VALUE = "Clear">
< /TD>
< /TR>
< /TABLE>
< /FORM>
No comments:
Post a Comment