Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

HTML inputs have APIs for checking their validation state. The input returning "" in invalid state is easy to test for:

const num = numInput.checkValidity() ? numInput.value : 0; // or some other default



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: