I want to test for this input: [an optional negative sign] 2 digits [an optional . and an optional digit] like this:
-34 or -34.5333 or
-34
-34.5333
Perhaps regex is not needed.
function validate(val){ return isNaN(val)?false:(Math.abs(Math.floor(val)).toString().length==2); }