PDA

View Full Version : check &submit



ahmedsoliman
Jun 17th, 2002, 09:06 PM
{
if (form1.fn.value ="")
{
alert("you must type your name")
return false
}
}
//-->
</script>
<form onsubmit="return check()" action=confirm.asp method=post name=form1 >

please fill the folowing form
First Name
<input name=fn >

<INPUT type="submit" value="Submit" name=submit1>


****************************************************
in prvious code i want to first to check if the text box is embty or not ,so it submit the form to asp file.
when i try the code it submit the form to asp without checking it
why??:rolleyes: :rolleyes: :rolleyes:

ACJavascript
Jun 17th, 2002, 09:26 PM
<script language="javascript">
function check(){
if (document.form1.fn.value=="")
{
alert("you must type your name")
}
}
//-->
</script>
<form action="confirm.asp" method="post" name="form1">


<input name="fn">

<INPUT type="submit" value="Submit" name="submit1" onclick="check()">

-------
Heres why it didn't work

1).value="" (incorrect)
should be .value==""
one = means that you are writing to the form.
two == means that it already has a value and you are checking it

2) "" always put quations "" around names and actions.


I hope this has helped. :thumbsup:


HappyScripting :D:D:D

whammy
Jun 18th, 2002, 02:20 AM
I would reply but I think AC has covered it

ACJavascript
Jun 18th, 2002, 02:23 AM
I agree hehehehehehe :thumbsup: :thumbsup: :D:D
Great new features this forum:p

whammy
Jun 18th, 2002, 02:28 AM
Also make sure that your onsubmit statement matches the function name and that it returns a boolean value (true or false).

If you're still having problems please post in return.

ahmedsoliman
Jun 18th, 2002, 11:16 PM
thanks for all
it is worked correctly
meny function include(this) word
why?