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? Link to comment https://forums.phpfreaks.com/topic/195781-checking-numbers-is-not-a-number-query/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.