»
EnglishFrenchVietnamese

Print - Check Form - JavaScriptBank.com

Full version: jsB@nk » Form » Validation » Check Form
URL: https://www.javascriptbank.com/check-form.html

Check Form © JavaScriptBank.comThis form validation script will place a check in the checkbox next to a textbox in a form if the enty is valid. Includes basic form validation. Cool!

Full version: jsB@nk » Form » Validation » Check Form
URL: https://www.javascriptbank.com/check-form.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">// Chris van Marle ([email protected])<!-- BeginFormName  = "form"  //Name of the formCheckName = "check" //Name of the checkboxes (without 1,2,3...10,11,12...)TextName  = "text"  //Name of the textfields (without 1,2,3...10,11,12...)var Condition=new Array('a!=""', //Must be filled'a!=""', //Must be filled'a!=""&&a.length>5&&a.indexOf("@")!=-1&&a.indexOf(".")!=-1', //Must be longer than 5 characters, have @, and atleast one '.''a.length>7&&!(a.split("/")[0]*1>12)&&!(a.split("/")[1]*1>31)&&!(a.split("/")[2]*1<1900)' //Must be longer than 7 characters, first (two) digit(s) NOT greater than 12, second (two) digit(s) NOT greater than 31 and last 4 greater than 1900);function docheck(w) {eval("a=document." + FormName + "." + TextName + w + ".value");if (eval(Condition[w])) eval("document." + FormName + "." + CheckName + w + ".checked=true");else eval("document." + FormName + "." + CheckName + w + ".checked=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 style="text-align: left; width: 50%;"><input type=checkbox name=check0 onClick="return false"> First: <input type=text name=text0 onBlur='docheck("0")'><BR><input type=checkbox name=check1 onClick="return false"> Last: <input type=text name=text1 onBlur='docheck("1")'><BR><input type=checkbox name=check2 onClick="return false"> E-Mail: <input type=text name=text2 onBlur='docheck("2")'><BR><input type=checkbox name=check3 onClick="return false"> Birthday (mm/dd/yyyy): <input type=text name=text3 onBlur='docheck("3")'><BR></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->