Allow only 2 decimal points entry to a textbox using javascript or jquery? -
i called class called test textbox. when entered first value e.g. first value 4., output coming 4.00. want restrict entry 2 decimal places.
$(".test").keyup(function (event) {     debugger;     this.value = parsefloat(this.value).tofixed(2); }); 
this small change code may suffice:
  this.value = this.value.replace (/(\.\d\d)\d+|([\d.]*)[^\d.]/, '$1$2'); essentially replace decimal point followed number of digits decimal point , first 2 digits only. or if non digit entered removes it.
Comments
Post a Comment