I am having an issue while I am validating a textbox with number upto 11 digits including decimal and two digits after decimal(if any). On keyup in jquery.
I used this regular expression /^(\d+)?([.]?\d{0,2})?$/g to validate for a number and decimal with two digits, but I do not know how to constraint digits max to 11.
I have used the input type number with maxlength but it's not working.
Html
<input type="number" />
jQuery
$('input').keyup(function() {
var $th = $(this);
$th.val( $th.val().match(/^(\d+)?([.]?\d{0,2})?$/g,
function(str) {
return ''; }
) );
});
Values like this
64123841.33 123456789.1 , 12345678901, 1.22,
Please Help me out with this.