Search code examples
javascriptjqueryjquery-validation-engine

Regex unexpected token


When I add this regex into validation engine I get a javascript error: "unexpected token", it seems that the regex is wrong because it is underline with red, why?

"time1":{    
   "regex": ^([0-9]|0[0-9]|1[0-3]|2[0-3]):[0-5][0-9]$,
   "alertText": "* Invalid Time"
}

Solution

  • Replace

       "regex": ^([0-9]|0[0-9]|1[0-3]|2[0-3]):[0-5][0-9]$,
    

    with

       "regex": /^([0-9]|0[0-9]|1[0-3]|2[0-3]):[0-5][0-9]$/,
    

    See the syntax of regex literals.