...

View Full Version : form



mag wa
02-02-2005, 01:00 PM
Could anybody check what is wrong with my code, it does not give me anything... shouldn't it at least if I don't write anything in the form to give me the alert....
how would I display the information given by the user in the form, in another page.
<HTML>
<HEAD>
<TITLE>FRAMES</TITLE>
<script Language="JavaScript">
<!--
function formSubmit()
{
document.forms.myForm.submit()
}

function validate()
{

x=document.myForm
search=x.search.value
minimum=x.minimum.value
maximum=x.maximum.value

if (search.length=0)
{
{
alert("you must supply a product name")
return false
}
else
{
return true
}
}

}//end of function validate


//-->
</script>
</HEAD>

<BODY BGCOLOR="lightblue">


<form name="myForm" onsubmit="return validate()">
Search Product: <input type="text" name="search" size="20"><br />
Minimum Price: <input type="text" name="minimum" size="20"><br />
Maximum Price: <input type="text" name="maximum" size="20"><br />
<br /><input type="button" onclick="formSubmit()" value="Submit"><INPUT TYPE="RESET">

</form>

</BODY>

</HTML> :(

Badman3k
02-02-2005, 01:40 PM
You're assigning 0 to search.length, not testing to see if it's equal to 0.



function validate()
{

x=document.myForm
search=x.search.value
minimum=x.minimum.value
maximum=x.maximum.value

if (search.length==0)
{
{
alert("you must supply a product name")
return false
}
else
{
return true
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum