2

I'm using this code for html:

<input pattern="/^[1-9]\d*$/g" id="num-input" type="number" min ="0" class="form-control number" placeholder="Input numbers here" aria-label="Input number here" aria-describedby="btn-generate"> 

and this is in my script.js file:

function numIntoUnits() { let num = $('#num-input').val() // let full_name = $("#register-full-name").val() console.log(num) } 

it still shows the input numbers with zero

1 Answer 1

1

Your regex look overcomplicated. /^[1-9]+$/ should do just fine.

Furthermore, setting min to 1 instead of 0 should suffice.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.