Full version: jsB@nk » Form » Validation » Required Fields
URL: https://www.javascriptbank.com/required-fields.html
Checks form fields to verify that each specified field is not left empty. Displays a warning message if any empty fields are present. Great!
Full version: jsB@nk » Form » Validation » Required Fields
URL: https://www.javascriptbank.com/required-fields.html
<SCRIPT LANGUAGE="JavaScript">// Wayne Nolting ([email protected])<!-- Beginfunction 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 submitif (themessage == "You are required to complete the following fields: ") {document.form.submit();}else {alert(themessage);return false; }}// End --></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form name=form method="post" action="" style="text-align: left; width: 50%;"><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><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->