Trying to create a contact form and realized that in the name input box, any character (ie. ~ / % @ # and etc.) and numbers can be entered.
<form enctype="multipart/form-data" action="/upload" method="post">
<input type="file" name="file">
<input type="submit">
</form>
Is there a bootstrap class or jQuery function that I can add to restrict the name input box to only the 26 alphabet? (Or at least no numeric value allowed...) Any help would be appreciated :)
答案 0 :(得分:2)
你可以用一些jquery来做。这样的事情:http://jsfiddle.net/ddan/ka52kdLv/2
<input class="alphaonly">
$('.alphaonly').bind('keyup blur',function(){
var node = $(this);
node.val(node.val().replace(/[^a-z ]/g,'') ); }
);
或者对于一个漂亮的解决方案,您可以查看一些验证库。