Helpful Information
 
 
Category: JavaScript programming
check &submit

{
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:

<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

I would reply but I think AC has covered it

I agree hehehehehehe :thumbsup: :thumbsup: :D:D
Great new features this forum:p

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.

thanks for all
it is worked correctly
meny function include(this) word
why?










privacy (GDPR)