Regular match, how to keep two decimal places

js Code

var old = "";

        function check(ele) {
            var pattern = /^(\+|\-)?((([1-9]([0-9]*))|0)(\.[0-9]*)?)?$/;
            var val = ele.value;
            if(val.match(pattern)) {
                old = val;
                return true;
            } else {
                ele.value = old;
                return false;
            }
        }

html Code
< input type= "text" size= "20" onkeyup= "check (this)" >

how does this rule retain two decimal places

Mar.09,2021

add {0jue 2} to the original.

/^(\+|\-)?((([1-9]([0-9]*))|0)(\.[0-9]{0,2})?)?$/
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35e49-3437d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35e49-3437d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?