Click to See Complete Forum and Search --> : How to ensure that when user type on the textbox format of DD-MM-YYYY will appear


verybrightstar
11-30-2003, 10:30 PM
hi all,
i would like user when type on the textbox a format will appear for eg DD-MM-YYYY , how to enforce the user input in such way?how do i do it in javascript?

ray326
11-30-2003, 11:37 PM
I use regular expressions for that kind of thing. Here's an example; look up the regex docs on the Netscape Developer Connection or any other good Javascript source.

"2-3-2004".match(/(\d{1,2})-(\d{1,2})-(\d{4})/)

The returns an array (if the match occurs):

2-3-2004, 2, 3, 2004

Otherwise it returns null.