Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if (document.form.user.vlaue="a") PROB 1

Status
Not open for further replies.

UnfitElf

Programmer
Dec 3, 2002
24
NZ
Hi all.. i started learning javascript about 2 days ago..
i have tryed to make a VERY simple Validate function.. here it is..

<SCRIPT TYPE=&quot;text/javascript&quot; LANGUAGE=&quot;JavaScript&quot;>
<!--
function Validate()
{
if (document.form.user.vlaue=&quot;a&quot;)
{
window.alert(&quot;Thanks&quot;)
}
}
//-->
</SCRIPT>

and this is the cade from my form:

<FORM NAME=&quot;form&quot;>
Username:<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;user&quot;>
<INPUT TYPE=&quot;SUBMIT&quot; NAME=&quot;BUTTON&quot; onClick=&quot;Validate()&quot;>

</FORM>


now why is it that i can enter any value into the textbox yet it will all ways give me the message &quot;thanks&quot;???

Thanks to all that help... :)
 
if (document.form.user.value == &quot;a&quot;)
{
alert(&quot;Thanks&quot;)
 
ok just one more question..

how do i join two if things together.. eg

i want to go something like..

function Validate()
{
if (document.form.user.vlaue=&quot;a&quot; and document.form.pass.vlaue=&quot;b&quot;)
{
window.alert(&quot;Thanks&quot;)
}
}

how would i do this???
 
Ok, you don't need window. for alert. alert alone is fine

if (document.form.user.value==&quot;a&quot; && document.form.pass.value==&quot;b&quot;)
{
alert(&quot;Thanks&quot;)
 
Hey thanks heaps 4 your help...

Thanks again u Legend lol.. thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top