Script Categories













Forms >>> Required Fields.

Checks form fields to verify that each specified field is not left empty. Displays a warning message if any empty fields are present.

First Name
Last Name
E-Mail


Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function verify() {
var themessage = "You are required to complete the following fields: ";
if (document.form.first.value=="") {
themessage = themessage + " - First Name";
}
if (document.form.last.value=="") {
themessage = themessage + " -  Last Name";
}
if (document.form.email.value=="") {
themessage = themessage + " -  E-mail";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.form.submit();
}
else {
alert(themessage);
return false;
   }
}
//  End -->
</script>
<form  name=form method="post" action="">
<input
type=text name="first" size="20"> First Name<BR>
<input type=text name="last" size="20"> Last Name<BR>
<input type=text name="email" size="20"> E-Mail<BR><BR>
<input type=button value="Submit Request" onclick="verify();">

<input
type=reset value="Clear Form"><br>
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©