Reg exp to accept only one comma in the number in oninput event in angular typescript

Viewed 90

I am trying to have textbox aceepts only numbers having only one dot or comma in the input value. below code works fine takes 1 dot

 <input type="text" id="Id" name="Name" 
        oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"
       >

but i also need to support one comma based on locale. can anyone please correct my reg exp which accepts one comma or if dot is taken comma shouldnt accept vice versa. thanks in advance

0 Answers
Related