esthera
05-28-2006, 03:57 PM
cna someone tell me how to do an input mask on a feild
it's a text box and as someone enters the date I want it to add the /
so it's formatted as mm/dd/yyyy (meaning after they enter in 2 numbers it adds the /
Philip M
05-28-2006, 05:04 PM
This is going to give problems. What if the date is 1st January or whatever? Users may not put in a leading zero.
I suggest much better to have separate input boxes for mm dd and yyyy, and concatenate and/or format the result afterwards.
Or try:-
if( !/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.test(obj.value) ) {
alert( "Invalid date supplied - must be format MM/DD/YYYY" );
obj.focus();
return;
}
You will still need to test if the values of mm dd and yyyy are valid.
Just found the following which is close to what you want:-
http://javascript.internet.com/forms/format-date.html
Hope this helps.
vwphillips
05-28-2006, 08:31 PM
http://www.vicsjavascripts.org.uk/FormCompendiumFormCompendium.htm#f20