Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 828
Juan Pablo Avatar asked Dec 09 '18 23:12

Juan Pablo


People also ask

What is validity in research?

Validity refers to the accuracy of the measurement. Validity shows how a specific test is suitable for a particular situation. If the results are accurate according to the researcher's situation, explanation, and prediction, then the research is valid.

What is the difference between @valid and @validated in Salesforce?

The @Valid annotation ensures the validation of the whole object. Importantly, it performs the validation of the whole object graphs. However, this creates issues for scenarios needing only partial validation. On the other hand, we can use @Validated for group validation, including the above partial validation.

Why is it important to verify and validate data?

If data isn’t accurate from the start, your results definitely won’t be accurate either. That’s why it’s necessary to verify and validate data before it is used. While data validation is a critical step in any data workflow, it’s often skipped over.

What is content validity and why is it important?

Content validity assesses whether a test is representative of all aspects of the construct. To produce valid results, the content of a test, survey or measurement method must cover all relevant parts of the subject it aims to measure.


1 Answers

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".

like image 199
Maarti Avatar answered Sep 25 '22 13:09

Maarti