开发者

Javascript Form Validation 4 Number Option

I've been searching this website for a tutorial on how to write a s开发者_开发问答cript that validates a form for four specific numbers. If the data is entered and does not match any of the four numbers, it should alert a 'Not Valid' message.


var input = document.getElementById("myInput");
var validNumbers = /^(123|777|989|111)$/;
var isFormValid = validNumbers.test(input.value);
if (!isFormValid)
{
    alert("Not Valid");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜