tauchai83 Posted January 27, 2007 Share Posted January 27, 2007 well, i have created a date field that user will key in. Format is yyyy-mm-dd....is there any javascript that can validate the user input? input is text type..... Quote Link to comment https://forums.phpfreaks.com/topic/35911-javascript-validation/ Share on other sites More sharing options...
bibby Posted January 28, 2007 Share Posted January 28, 2007 [code]//lol, great name for this fxn.function valiDate(input) { if(document.getElementById(input)) { //gave it an id ? var ymd=input.value.split('-'); if (ymd[0].length=='4' && !isNan(ymd[0])) { // is a number by !isNan? (not (is not a number)?) var yeargood=true; } else { var yeargood=false; } // ect. same for month, same for day. // return in the end, true or false, handle as you see fit. } // else there is no id for that input}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35911-javascript-validation/#findComment-170889 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.