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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript validation option box

Status
Not open for further replies.

romerz

IS-IT--Management
Jul 19, 2006
29
GB
Basically I have a form that has

--------------------------------

as an option to make a line (because the options in the drop down box are coming from a database)

I have validation for everything,

the bit that checks that something has been selected is

x=frm.country[0];
if (x.selected) {
alert ('Blah blah');
return false;
}

How would i make it so it checks to see if the line has been chosen.

Ive tried

x=frm.country[0];
if (x.value ='--------------------------------') {
alert ('Blah blah');
return false;
}

But no luck and when i use just '-' it stops all of them.

Thanks for your help in advance :)
 
Whatever you mean!
>if (x.value ='--------------------------------') {
[tt]if (x.value [red]=[/red]='--------------------------------') {[/tt]
 
in some cases the item you need to look at is the text rather than the value :

<option value="a">1</option>

here the VALUE property is 'a', but the TEXT property is '1'

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top