Regex Javascript. Why are my curly braces not working? -


i confused why curly braces seem ignored in code? if run command in console seems work fine.

datetime: function(field) {   var regex = /^\d{1,2}$/;    if (field.val().length > 0) {      // works in console /^\d{1,2}$/.test("22");     console.log(regex) // /^\dundef$/     console.log(typeof regex); // object     console.log(typeof field.val()); // string     return regex.test(field.val());   } else {     return true;   } } 

thanks frédéric hamidi, light bulb went off in head.

the reason curly braces coming undef due java backend tagging system. should keep javascript away template in own file!!

thanks frédéric hamidi :)


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -