Validation Code Help........

Status
Not open for further replies.

satyamy

Alive Again...
Can Someone find out error in this code
its a Validation Code
<HTML>
<HEAD>
<TITLE> Validation Code </TITLE>

<Script language="JavaScript">
<!--
function validate()
{
l1=document.form1.txt_name.value
if(l1=="")
{
alert("Enter Your Namef")
document.form1.txt_name.focus();
return false
}
else
{
for(i=0;<l1.length;i++)
if(l1.charAt(i)>'Z'&&l1.charAt(i)<'a') || (l1.charAt(i)<'A') || (l1.charAt(i)>'z'))
{
alert("Enter a Valid Name")
document.form1.txt_name.focus()
return flase
}
}
-->
</script>

</HEAD>

<BODY>
<form name="form1">
Name
<input type="text" name="txt_name">
<input type="button" name="submit" value="submit" onClick="validate();">
</FORM>
</BODY>
</HTML>
 

ahref

In the zone
Here is the correct code
Code:
<HTML>
<HEAD>
<TITLE> Validation Code </TITLE>
<script language="JavaScript">
<!--
function validate()
{
l1=document.form1.txt_name.value
if(l1=="")
{
alert("Enter Your Namef")
document.form1.txt_name.focus();
return false
}
else
{
for(i=0;i<l1.length;i++)
{
if ((l1.charAt(i)>'Z')&&(l1.charAt(i)<'a') || (l1.charAt(i)<'A') || (l1.charAt(i)>'z'))
{
alert("Enter a Valid Name")
document.form1.txt_name.focus()
return false
}
}
}
}
-->
</script>

</HEAD>

<BODY>
<form name="form1">
Name
<input type="text" name="txt_name">
<input type="button" name="submit" value="submit" onClick="validate()">
</FORM>
</BODY>
</HTML>
 
Status
Not open for further replies.
Top Bottom