Re: regex question - trying to find ".mp3" in a SELECT box



Jake Barnes said the following on 5/30/2006 5:00 PM:
I've a form for creating podcast episodes. The user can pick an MP3
from a drop down box (an HTML select box). I'm trying to add some error
checking. In the code below, I try to get the value of the select box,
and then I try to see if it contains the string ".mp3". I'm getting the
alert message every time. Why is that?

var selectValue = document.forms['formID'].elements['selectName'.value;

if (selectValue.indexOf('.mp3') != -1){
alert('Your value has .mp3 in it')
}
else{
alert('Your value does not have .mp3 in it')
}

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
.



Relevant Pages