Script Categories













Forms >>> Basic Validation.

The simplest way to require visitors to fill out certain fields is to us this script - just add the word "required" to each required field's name and your visitor must fill it out to submit the form!

Name:     
Email:    
Hobby:    
Comments: 

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 checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("Please make sure the "+shortFieldName+" field was properly completed.");
return false;
}
else
return
true;
}
//  End -->
</script>
<form onSubmit="return checkrequired(this)">
<pre>
Name:     <input type="text" name="requiredname">
Email:    <input type="text" name="requiredemail">
Hobby:    <select name="requiredhobby">
<option
selected>Pick an option!
<option>1
<option>2
<option>3
</select>
Comments: <textarea name="requiredcomments"></textarea>
<input
type=submit value="Submit">
</pre>
</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!).

Bitcoin Gambling - The Original Crypto Dice Game . The best website backlink analysis.


©