Form validator

 
Your Name  
E-mail:
Your comments:





Put this between your HEAD-tags
<script >
function validate(){
var err;
err=0;{
if (document.FB.Name.value=="") {
document.FB.name_E.value = '*ERROR:Please enter your name';err=1;
return false
}else document.FB.name_E.value = '';
if (document.FB.Email.value.search("@") == -1 || document.FB.Email.value.search("[.*]") == -1){
document.FB.email_E.value = '*ERROR:Please enter a valid e-mail address';err=1;
return false}}
if (err==0) document.write('<center><font color=red size="+2" >Ok!Data sent!</font>');//Please remove this when you fill the "action" field on your FORM
}
</script>


This is my form if you want to copy it:
<form name=FB action="" onSubmit="return validate()">
<table class=tdfont cellspacing="0" cellpadding="4" border="0">
<TBODY><tr><td align="left">
<table class=tdfont cellspacing="0" cellpadding="4" border="0"><tr><td>
Your Name
</td><TD>
<INPUT style="FONT-SIZE: 11px; WIDTH: 200px; COLOR: navy; BACKGROUND-COLOR: orange" size="15" name="Name" onfocus="document.FB.name_E.value = ''">
</td><td>
  <INPUT style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; FONT-SIZE: 11px; BORDER-LEFT: medium none; WIDTH: 200px; COLOR: red; BORDER-BOTTOM: medium none; BACKGROUND-COLOR: white" size=15 name=name_E>
</td></tr><tr><td>
E-mail:
</td><TD>
<INPUT style="FONT-SIZE: 11px; WIDTH: 200px; COLOR: navy; BACKGROUND-COLOR: orange" size="15" name="Email" onfocus="document.FB.email_E.value = ''">
</TD><td>
<input name="email_E" size="15" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; FONT-SIZE: 11px; BORDER-LEFT: medium none; WIDTH: 300px; COLOR: red; BORDER-BOTTOM: medium none; BACKGROUND-COLOR: white">
</td></tr><tr><td colspan="2">
<STRONG><FONT face=Tahoma color=#000080 size=2>Your comments:</FONT></STRONG><br>
<TEXTAREA style="FONT-SIZE: 11px; WIDTH: 350px; COLOR: navy; FONT-FAMILY: tahoma,arial; BACKGROUND-COLOR: white" name=Comments rows=7 wrap=VIRTUAL cols=30></TEXTAREA>
</td></tr><tr><td>
<input type="submit" name="submit" value="Send" style="FONT-WEIGHT: bold; BACKGROUND: orange; COLOR: white">
</td>
<input type="reset" name="reset" value="Reset " style="FONT-WEIGHT: bold; BACKGROUND: orange; COLOR: white"> 
</tr></table>
</form></TD></TR></TBODY></TABLE>

Free JavaScripts provided
by Winfolinx.com


Back