Javascript regex help -


Does anyone know how I can make the next flash and format: DD / MM / yay in this reggae mandatory?

  // Checks a string to see if this is the valid date format // D (D) D / (M) M / (YY) YY and correct / Returns the wrong function isValidDate (s) {// format D (D) / M (M) / (YY) YY var dateFormat = / ^ \ d {1,4} [\. | \ / || -] \ d {1,2} [\. | \ / || -] \ d {1,4} $ / / If (dateFormat.test (s)) {// date values ​​s = s.replace (/ 0 * (\ d *) / gi, "$ 1") removes any leading zeros; Var dateArray = s.split (/ [\. | \ / | -] /); // True Month Price Dated [1] = DateRay [1] -1; // If the value of the right year is (dateiera [2]. Length <4) {// right year value date around [2] = (parseint (dateire [2]) <50)? 2000+ Parsyint (Dietayer [2]): 1900 + parsint (Dayayeré [2]); } Var testDate = new date (date around [2], dated [1], dated [0]); If (testDate.getDate () !: DateArray [0] || testDate.getMonth ()! = DateRe [1] || testDate.getFullYear ()! = DateRe [2]) {return false; } And {return true; }} And {return false; }}  

Try dd / mm / yyyy for compulsory:

  var dateFormat = / ^ \ d {2} \ / \ d {2} \ / \ d {4} $ / /  

It was not visible, but I think that's what you wanted.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -