...

View Full Version : simple validation



usha parupudi
02-16-2007, 09:56 AM
hi every body,
i have a problem in validating a text field. the problem is i have written code in such a way that the particular field is validated but after an alert message pop up it is not focusing to particular field. it is directly going to next page.
can any one suggest a solution as how to make focus on that particular field
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>

<script type="text/javascript">
<!--
function regval()
{
if(name= " ")
{
alert("Please Enter the Name");
document.name.focus();
return false;
}
else
return true;


}
function name()
{
if(name= " ")
{
alert("please enter the name");
return false;
}
else
return true;
}
-->
</script>

</head>

Spudhead
02-16-2007, 10:30 AM
Post your code?

usha parupudi
02-16-2007, 11:03 AM
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>

<script type="text/javascript">
<!--
function regval()
{
if(name= " ")
{
alert("Please Enter the Name");
document.name.focus();
return false;
}
else
return true;


}
function name()
{
if(name= " ")
{
alert("please enter the name");
return false;
}
else
return true;
}
-->
</script>

</head>

mrjameer
02-17-2007, 09:52 PM
hi usha

<script language="javascript">
function validate()
{
if(document.getElementById("name").value == "")

{
alert("Please Enter Your name");
document.getElementById("name").focus();
return false;
}
else if(document.getElementById("address").value == "")

{
alert("Please Enter Your address");
document.getElementById("address").focus();
return false;
}
}
</script>
<form name ="frm" method="post" onsubmit="return validate(this);">

ok
mrjameer.

Philip M
02-17-2007, 10:20 PM
This sort of simple validation where the user may enter anything into the name and address fields, even a single space or a digit, is virtually worthless.

mrjameer
02-18-2007, 05:54 PM
hi,

this is the simple validation.you have to take care about the code in such a way that the user canot enter the blank spaces,dots, name in number textbox and similarly number in name textbox and also you have to take care about date validations,email validations,check name should be certailn length characters.like this.....etc..

ok
mrjameer



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum