Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Searching strings for matching text

Reply
Thread Tools

Searching strings for matching text

 
 
Joeyej
Guest
Posts: n/a
 
      04-15-2004
Hi -

Wondering if anyone knows how to code a function fieldcheck to prevent
users from choosing the same date from dual drop list on my web form
using this include file example;

<option value="none">Scroll through the list to choose a date
<option value="May 11 2004, (Tuesday), 1pm">May 11 2004, (Tuesday),
1pm
<option value="May 11 2004, (Tuesday), 2:30pm">May 11 2004, (Tuesday),
2:30pm

I'd prefer to alert the user (return false) if this string ">May 11
2004, is the same as this string ">May 11 2004, on the next line of
the include file.

I now have this code working nicely to prevent the same choice;

FirstCh=document.laptop.FirstCh.value
SecondCh=document.laptop.SecondCh.value

if (FirstCh == "none" || SecondCh == "none" || FirstCh == SecondCh) {
alert("Please choose two [different] dates/times for your laptop
delivery.")
document.laptop.FirstCh.focus()
return false
}

....but I'd prefer to alert the user (return false) if this string
">May 11 2004, is the same as this string ">May 11 2004, on the next
line of the include file.

Your help is greatly appreciated.

Thanks,

Joe
 
Reply With Quote
 
 
 
 
Michael Winter
Guest
Posts: n/a
 
      04-17-2004
On 15 Apr 2004 16:02:38 -0700, Joeyej <(E-Mail Removed)>
wrote:

[snip]

> ...but I'd prefer to alert the user (return false) if this string
> ">May 11 2004, is the same as this string ">May 11 2004, on the next
> line of the include file.


/* This extracts the date section (all text before
* the first comma) so it can be compared.
*/
var fCD = FirstCh.substring( 0, First.indexOf( ',' ));
var sCD = SecondCh.substring( 0, Second.indexOf( ',' ));

if(( 'none' == FirstCh ) || ( 'none' == SecondCh ) || ( fCD == sCD ))
{
/*...*/
}

Hope that helps,
Mike

--
Michael Winter
http://www.velocityreviews.com/forums/(E-Mail Removed)d (replace ".invalid" with ".uk" to reply)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
matching strings in a large set of strings Karin Lagesen Python 13 05-03-2010 03:53 PM
External Hashing [was Re: matching strings in a large set of strings] Helmut Jarausch Python 3 04-30-2010 08:44 PM
How to replace all strings matching a pattern with correspondinglower case strings ? anonym Java 1 01-15-2009 07:29 PM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
Searching and replacing multiple strings in text Chris Java 5 10-11-2003 05:12 AM



Advertisments