Frontpage - formatting a textbox for date entry mm/dd/yyyy

mfinocc
mfinocc used Ask the Experts™
on
Does anyone know how to set up the textbox so that a date can only be entered in mm/dd/yyyy? A calendar date selector could work too id you have the code.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
James MurrellProduct Specialist

Commented:
try this just need to change bottom part as for uk
try this simple javascript
 
function dateValidation()
{
 
var obj = document.getElementById("<%=txtDate.ClientID%>");
var day = obj.value.split("/")[0];
 
var month = obj.value.split("/")[1];
var year = obj.value.split("/")[2];
 
if ((day<1 || day >31) || (month<1&&month>12)&&(year.length != 4))
{
 
alert("Invalid Format");return false;
}
 
else
 
{
 
var dt = new Date(year, month-1, day);
var today = new Date();
 
if((dt.getDate() != day) || (dt.getMonth() != month-1) || (dt.getFullYear()!=year) || (dt>today))
{
 
alert("Invalid Date");return false;
}
 
}
 
}

Open in new window

Commented:
This is one of the best calendar widgets I have used....it is easy to implement and works great across all browsers.

http://www.dynarch.com/projects/calendar/old/

Curtis McBroom

Author

Commented:
Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial