function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion 

Javascript to accept only numbers


 I have a below validaition rule that accepts only numbers I need add one more condition that it must not take 0 as a single value it can allow 10 20 30 etc as a combination values but not just as a single 0 as a value should not be allow please suggest me how to add this logic in below code.
function inputLimiter(e,allow) {
            var AllowableCharacters = '';

            if (allow == 'Letters'){AllowableCharacters=' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';}
            if (allow == 'Numbers'){AllowableCharacters='1234567890';}
            if (allow == 'NameCharacters'){AllowableCharacters=' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.\'';}
            if (allow == 'NameCharactersAndNumbers'){AllowableCharacters='1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-\'';}
            if (allow == 'Currency'){AllowableCharacters='1234567890.';}

            var k = document.all?parseInt(e.keyCode): parseInt(e.which);
            if (k!=13 && k!=8 && k!=0){
                if ((e.ctrlKey==false) && (e.altKey==false)) {
                return (AllowableCharacters.indexOf(String.fromCharCode(k))!=-1);
                } else {
                return true;
            } else {
                return true;

Vivek DVivek D
You can try this
var yourVariable;

  alert('This is not a number');
}else if(Math.abs(youVariable/1) <=  0){
 alert('The Number is zero');
  alert('Yes it is a Number');

// Note the above code will allow negative values if you don't want negetive values just remove Math.abs  and use yourVariable/1 <= 0