Regular Expression for number 1-9 only

Use the regular expression and check if the value is any thing that contains the combination of 1- 9 only

by Varun Krishna P

HTML

<input type= "text" class="txt1" placeholder="Enter number"/>
<input type="button" class="btn" value= "validate"/>

JavaScript

var oneToNineRE = /^[1-9]+$/;
$(function() {
    alert("Load");
    $(".btn").click(function(){
        if(!oneToNineRE.test($(".txt1").val())){
            alert("Did not match");
        }else{
            alert("Match");}
    });
});