»
Tiếng AnhTiếng PhápTiếng Việt

In - Kiểm tra dữ liệu của form - JavaScriptBank.com

Phiên bản đầy đủ: jsB@nk » Biểu mẫu » Hạn chế » Kiểm tra dữ liệu của form
URL: https://www.javascriptbank.com/required-fields.html

Kiểm tra dữ liệu của form © JavaScriptBank.comMột đoạn mã JavaScript khác để tạo hiệu ứng kiểm tra dữ liệu các khung nhập liệu do người dùng nhập vào.

Phiên bản đầy đủ: jsB@nk » Biểu mẫu » Hạn chế » Kiểm tra dữ liệu của form
URL: https://www.javascriptbank.com/required-fields.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">// Wayne Nolting (w.nolting@home.com)<!-- 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-->


HTML
<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-->