Reputation: 317
<input type="number" id="fname" name="fname">
<input type="submit" onclick="fun()" value="Submit">
function fun(){
var x= document.getElementById("fname").value;}
How to strip coma from it before any process start. Help. It show Zero only nothing that is good.
Code Updated with full detail.
Problem for me is number type for coma , not doing any favor.
Other option look use type=text in HTML. Problem with me to import from HTML to java-script. and value
https://codepen.io/puneetxp/pen/PoPMXEQ
Thanks guys for fast help.
I Found the Solution threw hint.
<input type="text" id="fname" name="fname">
var x= document.getElementById("fname").value.replace(/,/g, '');
Turn Out the Type number can't handle , (comas). But still anybody know it can work with number then let me know.
Upvotes: 1
Views: 101
Reputation:
the reason why it show only a zero is because you did not do the oninput=“function()”
<= when the user inputs something, the function in quotes is called, if you don’t put this, then when the user does input something nothing happens, this causes the 0
or Null
Upvotes: 0