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
Post a Comment