1170 Part V . Putting JavaScript (Space web hosting) to Work

1170 Part V . Putting JavaScript to Work The parseInt() functions reveal whether any entry is not a number by returning NaN, so I check whether any of the three values is not a number. If so, then an alert signals the formatting problem and supplies acceptable models. if (isNaN(mm) || isNaN(dd) || isNaN(yyyy)) { // there is a non-numeric character in one of the component values alert( The date entry is not in an acceptable format.nnYou can enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy. ) gField.focus() gField.select() return false } Next, I perform some gross range validation on the month and date to make sure that months are entered from 1 to 12 and dates from 1 to 31. I take care of aligning exact month lengths later. if (mm < 1 || mm > 12) { // month value is not 1 thru 12 alert( Months must be entered between the range of 01 (January) and 12 (December). ) gField.focus() gField.select() return false } if (dd < 1 || dd > 31) { // date value is not 1 thru 31 alert( Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year). ) gField.focus() gField.select() return false } // validate year, allowing for checks between year ranges // passed as parameters from other validation functions Before getting too deep into the year validation, I convert any two-digit year within the specified range to its four-digit equivalent. if (yyyy < 100) { // entered value is two digits, which we allow for 1930-2029 if (yyyy >= 30) { yyyy += 1900 } else { yyyy += 2000 } } var today = new Date() I designed this function to work with a pair of year ranges or date ranges (so many days before and/or after today). If the function is passed date ranges, then the first two parameters must be passed as null. This first batch of code works with the date ranges (because the minYearparameter is null).
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Leave a Reply