Answers for "how to accept only numbers in javascript"

1

js get numbers only

var str = "Rs. 6,67,000";
    var res = str.replace(/D/g, "");
    alert(res); // 667000
Posted by: Guest on March-23-2021
0

input only accept numbers

<label for="salary">Enter your salary:</label>
<input type="text" id="salary" name="salary"
    oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(..*)./g, '$1');" />
Posted by: Guest on December-10-2021

Code answers related to "how to accept only numbers in javascript"

Browse Popular Code Answers by Language