richrock Posted March 19, 2010 Share Posted March 19, 2010 Hi, I'm doing some validation on a form, and just need to fine-tune one part of it - the dates are entered numerically, eg 01-02-10, and want to ensure that a number is used for the date. So I did this: if (practitioner_month_referred == null || practitioner_month_referred == "" || practitioner_month_referred == "<?php echo $monval; ?>" || isNaN(practitioner_month_referred)) { if (focused == false ) { document.getElementById('practitioner_month_referred').focus(); focused = true; } if(isNaN(practitioner_month_referred)) { numvalid = false; } else { numvalid = true; } document.getElementById('practitioner_month_referred').style.color="<?php echo $formcol_3; ?>"; document.getElementById('practitioner_month_referred').style.fontWeight="bold"; valid = false; } But, it seems that if I type in 01 as a month in this example, is tells me that this is not a number (by the big red error message from numvalid being switched to false. Is the isNaN right? Or is there some other way of checking that it is in fact a number, not letters or anything else? Quote Link to comment 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.