Use regex to match a value in form input
I'm trying to create a branching form wherein the user selects a date using the datepicker plugin, then, depending on whether they choose a weekday or a Saturday, they are presented with one or the other of 2 select lists to choose the time.
I'm just getting started, and I can't seem to get the regex right. Here's a simplifed version of the relevant part of the datepicker,
- $(function() {
- $(".datepicker").datepicker({dateFormat: 'D, mm-dd-yy',buttonText: 'Click Me!', });
- });
and here's the initial test to see if the chosen date falls on a weekday or a Saturday:
- $(document).ready(function() {
- $(':input[name=datepicker]').change(function() {
- if ($(this).val()!=/^Sat,.*/)
- {
- alert('You picked a weekday delivery');
- }
- else
- {
- alert('Saturday? Are you kidding?');
- }
- });
- });
I guess I don't understand how to use a regex with val(), because I'm getting the 1st alert no matter what date I pick. I've also tried:
- if ($(this).val()!=/^Sat, \d{2}-\d{2}-\d{4}$/)
with similar results.
Thanks for your interest,
--cz