473,513 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ 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 34456
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
1427
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
13993
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
1965
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
31794
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
2627
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
8693
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
3624
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
2
3137
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
3424
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7525
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
4746
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
3234
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
1596
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
802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.