Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-02-2005, 01:00 PM   PM User | #1
mag wa
New to the CF scene

 
Join Date: Jan 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
mag wa is an unknown quantity at this point
Unhappy form

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>
mag wa is offline   Reply With Quote
Old 02-02-2005, 01:40 PM   PM User | #2
Badman3k
Regular Coder

 
Join Date: Jun 2002
Location: Edinburgh, UK
Posts: 402
Thanks: 2
Thanked 1 Time in 1 Post
Badman3k is an unknown quantity at this point
You're assigning 0 to search.length, not testing to see if it's equal to 0.

Code:
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
}
}
__________________
Rich

"An expert is a person who has made all the mistakes that can be made in a very narrow field."
Badman3k is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:59 PM.


Advertisement
Log in to turn off these ads.