There is an inbuilt function for it
The function provided is
parseInt We can use it in two ways
1) Parsing the value to default number type
2) Parsing the value to a special
number system The usage for both respectively is:
1)
alert(parseInt("10")) // Or value or innertext of a control
alert(parseInt('aaa')) // Or value or innertext of a control, it will return Nan, showing that the value is not a number
2)
alert(parseInt("10",numbertype)) , e.g. alert(parseInt("10",10)) //etc. Or value or innertext of a control
there are different number types to which the given input can be parsed as per the requirement.