My Account   Contact Us    
  
» HomeProductsSupportDeveloper CommunityCompany
CODE-Validating Form
Author: DEEPARAJESH
Category: HTML
Code for validating form using script for registering mail ID

<html>
<title>MAILER </title>
<head>
<script language="vbscript">
DIM N
sub window_onload()
f1.mailid.focus
end sub


sub mailid_onblur
if f1.mailid.value="" then
msgbox "PLEASE GIVE YOUR MAILID",vbcritical,"WARNING"
f1.mailid.focus
end if
end sub

sub hq_onclick
f1.ha.focus
end sub

sub city_onchange
if f1.city.value="Trichy"  or  f1.city.value="Tanjore"  or  f1.city.value="Kumbakonam" or  f1.city.value="Madurai" or  f1.city.value="Chennai" or  f1.city.value="Nammakal" then
f1.sta.value="TamilNadu"
f1.sta.disabled=true
end if
if f1.city.value="Trivandrum" then
f1.sta.value="Kerala"
f1.sta.disabled=true
end if
if f1.city.value="Bangalore" then
f1.sta.value="Karnataka"
f1.sta.disabled=true
end if
if f1.city.value="Hyderabad" then
f1.sta.value="AndraPradesh"
f1.sta.disabled=true
end if
if f1.city.value="None" then
f1.sta.value="None"
f1.sta.disabled=true
end if
end sub

sub zcode_onblur()
if not isnumeric(f1.zcode.value)  then
msgbox "ZIPCODE  IS  ALWAYS  A  NUMBER",vbcritical,"WARNING"
f1.zcode.value=""
f1.zcode.focus
else
if not (len(f1.zcode.value)=6)  then
 msgbox "pl give a valid data"
f1.zcode.value=""
f1.zcode.focus
end if
end if
end sub


sub sub_onfocus()
if not isnumeric(f1.ph.value)then
msgbox "PL insert number"
f1.ph.value=""
f1.ph.focus
else
     if not( len(f1.ph.value)<=7 and  len(f1.ph.value)>=6) then
         msgbox "pl . give  valid phone # "
 f1.ph.value=""
 f1.ph.focus
      end if
end if
end sub

sub cpwd_onblur
if len(f1.pwd.value)>7 then
if  f1.pwd.value<>f1.cpwd.value then
f1.pwd.value=""
f1.cpwd.value=""
f1.pwd.focus
msgbox "PLEASE GIVE THE CORRECT PASSWORD",,"WARNING"
end if
else
msgbox "Please Enter minimum of eight characters"
f1.pwd.value=""
f1.cpwd.value=""
f1.pwd.focus
end if
end sub

sub  sub_onclick
f1.sta.disabled=false
end sub

</script>
</head>
<body  bgcolor=#83d6f8 text=blue>
<form name="f1"  method=post  action="/code_samples/codecfm/CodeID/146/HTML/CODE_Validating_Form/xxx.html"><br><br>
<center ><B><font color=blue  size=5>MAILER</font></b></center>
<hr   color=blue><br><br>
<center><font color=blue  size=5>Please Fill up this Registration Form:</font></center>
<br><br><br>
<table align=center>
<tr>
<td>
MAILID :<td><input type="text"  name="mailid" >
<font color=blue> <b>"@XXX.com"</b></font>
</tr>
<tr>
<td>
PASSWORD:<td><input type=password  name="pwd" >
</tr>
<tr>
<td>
CONFIRM PASSWORD :<td><input type=password  name="cpwd" >
</tr>
<tr>
<td>
HINT QUESTION:<td><select name="hq">
<OPTION>
<option>WHAT IS YOUR PET NAME?
<option>WHAT IS YOUR BEST FRIEND NAME?
<option>WHAT IS YOUR PET ANIMAL NAME?
<option>WHAT IS YOUR SCHOOL NAME?
<option>WHAT IS YOUR COLLEGE NAME?
<option>WHO IS YOUR FAVOURITE ACTOR ?
<option>WHO IS YOUR FAVOURITE ACTRESS ?
<option>WHO IS YOUR FAVOURITE CRICKETER ?
<option>WHO IS YOUR FAVOURITE PERSONALITY?
<option>WHICH IS YOUR FAVOURITE PLACE?
<option>WHICH IS YOUR FAVOURITE MOVIE?
<option>WHICH IS YOUR FAVOURITE ICE CREAM?
<option>WHICH IS YOUR FAVOURITE FRUIT?
<option>WHICH IS YOUR FAVOURITE COUNTRY?
</SELECT>


</tr>
<tr>
<td>
HINT ANSWER :<td><textarea name="ha" rows=3 cols=30></textarea>
</tr>
<tr>
<td>
FIRST NAME:<td><input type="text"  name="fname" >
</tr>
<tr>
<td>
LAST NAME :<td><input type="text"  name="lname" >
</tr>
<tr>
<td>

BIRTH DAY:<TD>
<SELECT  name="month">
<OPTION>
<OPTION value="JAN">JANUARY
<OPTION  value="FEB">FEBRUARY
<OPTION  value="MAR">MARCH
<OPTION  value="APR">APRIL
<OPTION value="MAY">MAY
<OPTION value="JUNE">JUNE
<OPTION value="JULY">JULY
<OPTION value="AUG">AUGUST
<OPTION value="SEP">SEPTEMBER
<OPTION value="OCT">OCTOBER
<OPTION value="NOV">NOVEMBER
<OPTION value="DEC">DECEMBER
</SELECT>
<SELECT  name="day">
<OPTION>
<OPTION>1
<OPTION>2
<OPTION>3
<OPTION>4
<OPTION>5
<OPTION>6
<OPTION>7
<OPTION>8
<OPTION>9
<OPTION>10
<OPTION>11
<OPTION>12
<OPTION>13
<OPTION>14
<OPTION>15
<OPTION>16
<OPTION>17
<OPTION>18
<OPTION>19
<OPTION>20
<OPTION>21
<OPTION>22
<OPTION>23
<OPTION>24
<OPTION>25
<OPTION>26
<OPTION>27
<OPTION>28
<OPTION>29
<OPTION>30
<OPTION>31
</SELECT>
<SELECT name="year">
<OPTION>
<OPTION>1970
<OPTION>1971
<OPTION>1972
<OPTION>1973
<OPTION>1974
<OPTION>1975
<OPTION>1976
<OPTION>1977
<OPTION>1978
<OPTION>1979
<OPTION>1980
<OPTION>1981
<OPTION>1982
<OPTION>1983
<OPTION>1984
<OPTION>1985
<OPTION>1986
<OPTION>1987
<OPTION>1988
<OPTION>1989
<OPTION>1990
<OPTION>1991
<OPTION>1992
<OPTION>1993
<OPTION>1994
<OPTION>1995
<OPTION>1996
<OPTION>1997
<OPTION>1998
<OPTION>1999
<OPTION>2000
<OPTION>2001
<OPTION>2002
</SELECT>
</TR>
<TR>
<TD>
GENDER:
<TD><INPUT TYPE=RADIO NAME=R1 value="MALE" >&nbsp;MALE &nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE=RADIO NAME=R1 value="FEMALE">&nbsp;FEMALE
</TR>
<tr>
<td>
ADDRESS:<td><textarea name="add1" rows=8 cols=25></textarea>
</tr>
<tr>
<td>
CITY:<td><select name="city">
<option value="None">None
<option value="Bangalore">Bangalore
<option value="Chennai">Chennai
<option value="Hyderabad">Hyderabad
<option value="Kumbakonam">Kumbakonam
<option value="Madurai">Madurai
<option value="Nammakal">Nammakal
<option value="Tanjore">Tanjore
<option value="Trichy">Trichy
<option value="Trivandrum">Trivandrum
</select>
</tr>
<tr>
<td >
STATE:<td>
<select name="sta">
<option value="None">None
<option value="AndraPradesh">AndraPradesh
<option value="Karnataka">Karnataka
<option value="Kerala">Kerala
<option value="TamilNadu">TamilNadu
</select>
</td></tr><tr>
<td>
ZIPCODE:<td><input type="text"  name="zcode" ></tr>
<tr><td>
PHONE NUMBER:<td><input type="text"  name="ph" >
</tr>
<tr><td><br><td><br></tr>
<tr><td><br><td><br></tr>
<tr>
<td>
<input type=submit name=sub  value="REGISTER">
<td><input type=reset name=res  value="RESET">
</tr>
</form>
</body>
</html>



Content Management Powered by ActivEdit  ActivEdit Browser Based WYSIWYG HTML Editor

More Code Samples

Sign up for our newsletter: | Subscribe with RSS: RSS
© ActivSoftware 1999 to 2005 | Privacy Statement