Link to home
Start Free TrialLog in
Avatar of Carid
Carid

asked on

Validate dates using dd/mm/yyyy and dd mmm yyyy

I have a datagrid of fields where the user has to input date in the format of dd/mm/yyyy.
Once  the date has been input it is then displayed in the format of dd mmm yyyy.

I want the validation to occur using the OnBlur event and if the date is correct then submit it to the server.
The validation will have  to exclude empty date fields and any with the format of dd mmm yyyy.

thank you

Avatar of Zvonko
Zvonko
Flag of North Macedonia image

The exclude statement looks like this:


if(theField.value=="" || theField.value.match(/^\d\d\s\w{3}\s\d{4}$/)){
   // excluded
}

Or if you need it inverted:

if(theField.value!="" && !theField.value.match(/^\d\d\s\w{3}\s\d{4}$/)){
   // to be checked
}


Avatar of Carid
Carid

ASKER

Hi Zvonko
Can you tell me what the pattern or .match value would be for a date formatted as dd mmm yyyy.

I want to be able to exclude any dates with this format as this will be what will displayed when the validation has been completed.

thankyou
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Carid

ASKER

Thank you
My validation works now
I will give you the points

Cheers Cari