PDA

View Full Version : connot assign to a function result


oracleguy
12-10-2002, 05:12 AM
I'm getting this error: connot assign to a function result

My code:


function SendOrder_onclick() {
//Validate customer information

if (document.Order.CustName.value=="")
{
alert("You must enter your name")
return false
}

var email = document.Order.CustEmail.value

if (email.length<5)
{
alert("You must enter a valid email address.")
return false
}

//if (email.match("@")!="")
// {
// alert("You must enter a valid email address.")
// return false
// }

if (email.match("orangepc.net")="orangepc.net")
{
alert("That is a restricted domain. Please enter a diffrent email adress")
return false
}
alert("All fields validated.")
return true
}


Here is the button code:


<INPUT type="button" Value="Send Order" name="SendOrder" onclick="SendOrder_onclick()">


I know I'm doing something wrong but what. Basically what I want the js function to do is to validate my form elements so i don't have to write as much server side stuff. And if it hits an error to alert the user then exit the function.

Thanks.

glenngv
12-10-2002, 05:41 AM
you did an assignment operator (=) instead of equality operator (==) :
if (email.match("orangepc.net")="orangepc.net")

but is match() a valid regexp method in the first place?

whammy
12-10-2002, 06:53 AM
I still do that sometimes... annoying ;)

oracleguy
12-11-2002, 05:30 AM
Yep that was it! :thumbsup: thanks.