talat
10-23-2004, 07:04 AM
hi friends
consider the senario for example if i am taking some input from user on my page and checking that the input should be a number for that imake a script shown below which is working fine
<script language="JavaScript">
function numbercheck1()
{
if (document.form1.text1.value=='')
{
alert('The box was empty. Please enter a number');
}
else
{
n=document.form1.text1.value.length;
for (i=0;i<n; i++)
{
cchar=document.form1.text1.value.charAt(i);
if (parseFloat(cchar)|| (cchar=='.')||(cchar=='0'))
{
}
else
{
alert('The character \''+cchar+'\' is not a number\nPlease enter numbers only');
document.form1.text1.value='';
break;
}
}
}
}
</script>
and call it onclick event of submit button
<input type="submit" name="Submit" value="Submit" onclick="numbercheck1()">
now my problem is
"WHEN I CLICK SUBMIT BUTTON IF I GAVE WRONG ENTRY IN THE TEXTBOX MYSCRIPT SHOW ALERT BUT ALSO TAKE ME TO THE PAGE MENTION IN ACTION OF FORM "
whati want is that itshould keep me to the same page when the entry is wrong and kep cursor focus on the first textbox of page take me to new page when entry is write
plz help me how to do that
consider the senario for example if i am taking some input from user on my page and checking that the input should be a number for that imake a script shown below which is working fine
<script language="JavaScript">
function numbercheck1()
{
if (document.form1.text1.value=='')
{
alert('The box was empty. Please enter a number');
}
else
{
n=document.form1.text1.value.length;
for (i=0;i<n; i++)
{
cchar=document.form1.text1.value.charAt(i);
if (parseFloat(cchar)|| (cchar=='.')||(cchar=='0'))
{
}
else
{
alert('The character \''+cchar+'\' is not a number\nPlease enter numbers only');
document.form1.text1.value='';
break;
}
}
}
}
</script>
and call it onclick event of submit button
<input type="submit" name="Submit" value="Submit" onclick="numbercheck1()">
now my problem is
"WHEN I CLICK SUBMIT BUTTON IF I GAVE WRONG ENTRY IN THE TEXTBOX MYSCRIPT SHOW ALERT BUT ALSO TAKE ME TO THE PAGE MENTION IN ACTION OF FORM "
whati want is that itshould keep me to the same page when the entry is wrong and kep cursor focus on the first textbox of page take me to new page when entry is write
plz help me how to do that