Click to See Complete Forum and Search --> : validation


buzzbo55
04-25-2003, 07:32 PM
Hi,
I am trying to use this function to validate and I get an error because the name starts with an exclamation and has a space(which are required conventions for my shopping cart)
I tried quotation marks with no luck and have tried researching but cannot find a remedy. Any input is greatly appreciated.

function validatechoice(frmname){
if(frmname.!SKU0002 Flavor1.value=="None"){
alert( "Please choose a flavor")
frmname.!SKU0002 Flavor1.focus()
return false
}
return true
}


...................................
<select name="!SKU0002 Flavor1">
<option selected value="None">Choose Flavor</option>
<option value="BBQ">BBQ</option>
<option value="Honey BBQ">Honey BBQ</option>
<option value="Spicy BBQ">Spicy BBQ</option>

</select>

khalidali63
04-25-2003, 07:40 PM
you should be able to use HTML entity value for exclaimation mark
&amp;excl;

buzzbo55
04-25-2003, 08:26 PM
Thanks,
I am still getting an error when I write it like this

function validatechoice(frmname){
if(frmname.&excl;SKU0002 Flavor1.value=="None"){
alert( "Please choose a flavor")
frmname.&excl;SKU0002 Flavor1.focus()
return false
}
return true
}:confused:

Nedals
04-25-2003, 09:11 PM
I not 100% sure on this, but I do not think you can use '!' in a form name. Nor should your name contain a space. If you restrict your form names to alphanumeric chars, you will not run into problems.

Hope that helps!

buzzbo55
04-25-2003, 09:27 PM
Thanks,
Unfortunately it is part of the naming convention for my shopping cart they require that I put"!" before the sku and a space then a short description.
I tried to get help with their e-support and they don't feel that it's their job to teach me js so I'm trying to resolve it on my own.

buzzbo55
04-25-2003, 09:34 PM
Works great
Thanks for your time...I appreciate it!

buzzbo55
04-25-2003, 09:56 PM
Good Info, thanks again