a question for the JavaScript gurus...

A forum for, well, anything really.
Gripes, moans, ideas or just general chit chat. EXCEPT SPAM!!! - Don't just register to post here - IT WILL GET DELETED!!!
Post Reply
wkilc
Super Advanced
Super Advanced
Posts: 60
Joined: Fri Sep 26, 2003 9:28 pm

a question for the JavaScript gurus...

Post by wkilc »

Hi all,

Forgive me for asking this here... but I now a lot of knowledgeable people frequent the Milonic boards.

I might be reaching, but this does have something to do with the Milonic menu, as the form in question uses the menu to populate some very long "virtual" pull-down menus. (Andy assisted me with this a few years back.)

Anyway, I am also using a JS form validation script on this form...

This line will catch and give an alert if ANY of the characters submitted in "r_First" text field contains a comma:

Code: Select all

if ( formobj.elements['r_First'].value.indexOf( "," ) != -1 )
How would I manipulate that line so that it would complain if there was NOT a comma included SOMEWHERE in the text field response?
(That is... "," is not the whole response... but it needs to exist somewhere in the submission.)

Thanks.

~Wayne
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Re: a question for the JavaScript gurus...

Post by Andy »

The value being returned is the position of the comma within the string.

Therefore if you get a minus one value the string has not been found, the following will fire if the comma is not found.

Code: Select all

if ( formobj.elements['r_First'].value.indexOf( "," ) == -1 )
wkilc
Super Advanced
Super Advanced
Posts: 60
Joined: Fri Sep 26, 2003 9:28 pm

Re: a question for the JavaScript gurus...

Post by wkilc »

Thank you Andy!
:D
~Wayne
Post Reply