Change JavaScript NaN Message to Something Else
I've got an input[type="text"]
that throws up a NaN error until another box is filled. I know why the message is appearing, that's not a problem, it's correct. I开发者_JAVA技巧'm just wondering if I can change 'NaN' to something more descriptive for the user.
if(isNaN(input.value)) {
input2.value = '';//or a message of your choice
}
Test the value with isNaN(value) and if true then handle it however you want.
精彩评论