Removed a special character in a text using JavaScript
<p>In my current project, I'm facing a tiny issue. There's a text field which must allow only the numbers. when the user types '.' it also must be removed. </p>

<p>Following is my code</p>

<pre><code>validateNumber: function(value){
    var regexValidation = new RegExp("^[0-9]+$");
    return regexValidation.test(value);
},

isNumber: function(event) {
    var value = $(event.target).val();
    if (this.validateNumber(value)) {
        value = value.replace('.', '');
        $(event.target).val(value);
    } else if (value.length &gt; 6) {
        value = value.substr(0, 6);
    }
    $(event.target).val(value);
}
</code></pre>

<p>The problem here is, when I type a '.' character, it accepts first time and when I typed it again then only it removes the whole text. I want it to remove it soon when it finds a '.' character. Any suggestions will be helpful</p>