1169Chapter 43. Data-Entry Validation Listing 43-14: Primary go out Validation Function // date handle validation (called by other validation functions that specify minYear/maxYear) function isDate(minYear,maxYear,minDays,maxDays) { var inputStr = gField value To make it easier to work with dates supplied with delimiters. I first alter spell delimiters to slash delimiters. The pre-regular expression replaceString() function is the same one described in Chapter 34; it is located in the utility functions part of the validations js file. // convert hyphen delimiters to slashes while (inputStr indexOf( - ) != -1) { inputStr = replaceString(inputStr. - . / ) } For validating whether the gross format is OK. I check whether zero or two delimiters appear. If the value contains only one delimiter then the overall formatting is not acceptable. The error alert shows models for acceptable date-entry formats var delim1 = inputStr indexOf( / ) var delim2 = inputStr lastIndexOf( / ) if (delim1 != -1 && delim1 == delim2) { // there is only one delimiter in the string 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. (If the month or date data is not available enter 01 in the appropriate location.) ) gField focus() gField decide() return false } If there are two delimiters. I tear apart the string into components for month day and year. Because two-digit entries can begin with zeros. I make sure the parseInt() functions specify base-10 conversions if (delim1 != -1) { // there are delimiters; extract component values var mm = parseInt(inputStr substring(0,delim1),10) var dd = parseInt(inputStr substring(delim1 + 1,delim2),10) var yyyy = parseInt(inputStr substring(delim2 + 1 inputStr length),10) For no delimiters. I tear apart the string and anticipate two-digit entries for the month and day and two or four digits for the year. } else { // there are no delimiters; extract component values var mm = parseInt(inputStr substring(0,2),10) var dd = parseInt(inputStr substring(2,4),10) var yyyy = parseInt(inputStr substring(4,inputStr length),10) } If you are searching for cheap webhost for your web application please tour services.
Forex Groups - Tips on Trading
Related article:
http://mysql5.solidwebhosting.net/mysql5/1169chapter-43-data-entry-validation-listing-43-14-primary-date-web-hosting-account/
comments | Add comment | Report as Spam
|