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
Your regex look overcomplicated. /^[1-9]+$/
should do just fine.
Furthermore, setting min
to 1 instead of 0 should suffice.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.