By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,602 Members | 1,533 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,602 IT Pros & Developers. It's quick & easy.

Searching strings for matching text

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 15 Apr 2004 16:02:38 -0700, Joeyej <jo*************@quinnipiac.edu>
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
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.