Regular expression example 1

xiaoxiao2021-03-06  41

In the process of working in the company's project group, a JavaScript Validation Framework for verifying the user's input data legitimacy. During this Framework implementation, after referring to some online resources, you wrote a function of a date check, which is full of this verification function, and the result has experienced many modifications.

FUNCTION

Validatedate (Year, Month, Day) {var regex = new regexp (/ s /

); Regex.test (day) && Regex.test (Month) &&

Regex.test (Year)) {var regexp = new regexp (/ d /

); If (! Regexp.test (day) ||! Regexp.test (Month) ||!

Regexp.test (Year)) Return ("The Date Fields Contains Non-Number."

); Var tempdatevalue = year "/" month "/"

Day; if (TempdateValue.Length <6 || TempdateValue.length> 10

Return ("The Length of Date Fields IS Invalid."

VAR TEMPDATE = New

Date (TempdateValue); if

(ISNAN (Tempdate) Return ("" The Scope of Date Fields IS INVALID. "

); If (Parseint (Yearint (Yearin)> 1900 && Parseint (Year) <2500 &&

((Tempdate.getutcFullyEar ()). Tostring () == Year) && (Tempdate.getMonth () == PARSEINT (MONTH) -1) &&

(Tempdate.getdate () ==

PARSEINT (DAY))) Return ("The date fields is ok."

ELSE

Return ("The Date Fields Is Invalid."

}}

转载请注明原文地址:https://www.9cbs.com/read-54039.html

New Post(0)