473,485 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Javascript date validation using dd/mm/yy format

3 New Member
Can anyone please guide me to a good resource for date validation in Javascript using dd/mm/yy format?
There are many sites using other formats but I have not come across
anything that uses dd/mm/yy.

Thanks in advance
Jan 17 '07 #1
6 34454
acoder
16,027 Recognized Expert Moderator MVP
You must be from the UK (just a guess!).

Split the string using date.split()

This should give you the day, month and year in an array assuming that it has been entered in the correct format in the first place. You can use a regular expression to check for that. Then adapt the code that you have found which already checks for the validity of the date, month and year, but in a different order.

If you need more help, post again.
Jan 17 '07 #2
Krazy K
3 New Member
You must be from the UK (just a guess!).

Split the string using date.split()

This should give you the day, month and year in an array assuming that it has been entered in the correct format in the first place. You can use a regular expression to check for that. Then adapt the code that you have found which already checks for the validity of the date, month and year, but in a different order.

If you need more help, post again.
Thank you for responding but I am sorry I did not quite understand the date.split(). I was looking for a resource that has the code already written which does date validation in dd/mm/yy format as opposed to dd/mm/yyyy.

I am just learning javascript and I need to get some date form fields validated. I was hoping to 'borrow' code that has already been written to do this, just don't know where to look for it since a search on google gives too many results.
Ta
Jan 17 '07 #3
AricC
1,892 Recognized Expert Top Contributor
Thank you for responding but I am sorry I did not quite understand the date.split(). I was looking for a resource that has the code already written which does date validation in dd/mm/yy format as opposed to dd/mm/yyyy.

I am just learning javascript and I need to get some date form fields validated. I was hoping to 'borrow' code that has already been written to do this, just don't know where to look for it since a search on google gives too many results.
Ta
There is some Date info here. Here is an article on validating dates.
Jan 17 '07 #4
Krazy K
3 New Member
Thanks for your help. Much appreciated. KK
Jan 18 '07 #5
razmataz
2 New Member
Hi,

Try using this :)

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     function isValidDate(sText) {
  3.         var reDate = /(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20\d{2})/;
  4.         return reDate.test(sText);
  5.     }
  6.     function validate() {
  7.         var oInput1 = document.getElementById("txt1");
  8.         if (isValidDate(oInput1.value)) {
  9.             alert("Valid");
  10.         } else {
  11.             alert("Invalid!");
  12.         }
  13.  
  14.     }
  15. </script>
Jun 1 '09 #6
deepak patel
1 New Member
this will not work for 29th Feb 2011. :(
Sep 29 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1421
by: GIMME | last post by:
Background ... I've created a web application that allows a user to create an HTML application from IE. The application itself creates an XML representation of a XHTML form. The XHTML...
1
13991
by: Rob | last post by:
I have a date text box (input type = text) in an ASP.NET/Javascript environment. I wanted to force the users to enter dates in a "__/__/____", "dd/mm/yyyy" or similar format. The textbox needs to...
0
1960
by: Brian Conway | last post by:
I am having some validation and insertion problems. I am using a date picker that takes the selected date and puts it to ("dd-MMM-yyyy") format, as this was the only format that Oracle would...
7
31790
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
5
2625
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze...
3
8690
by: pmarisole | last post by:
The following javascript code gives me the date validation that I need except after the correct date is entered into the field, it puts the date in the wrong format EXAMPLE: User enters...
8
3620
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
2
3129
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
5
3423
Stang02GT
by: Stang02GT | last post by:
I have been asked to validate a date on our web-page so that people cannot enter dates like 14/1/08 or 2/30/06. I have found code that will do exactly what i need it to do, but i am not sure how to...
0
7161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7275
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5418
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4857
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4551
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3058
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3063
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1376
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
595
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.