I'm using this code for html:
<input pattern="/^[1-9]\d*$/g" id="num-input" type="number" min ="0" 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
CodePudding user response:
Your regex look overcomplicated. /^[1-9] $/
should do just fine.
Furthermore, setting min
to 1 instead of 0 should suffice.