Q:

How does validity.valid works?

I was trying to set an input number (html) to only positive numbers and I found this fine solution:
    <input type="number" name="test_name" min="0" oninput="validity.valid|| 
    (value='');">

Can anyone tell me how does oninput="validity.valid||(value=''); works? How does it restrict the input to only positive numbers.
Thank you!

A:

min="0" only accept numbers greater than zero. So when the user enters a value (oninput), either it is valid (validity.valid) or (||) the value is replaced by an empty string (value='').

Edit:
validity.valid is falsy because of min="0" as we can see in the doc under the rangeUnderflow property:

"if the value is less than the minimum specified by the min attribute".

