我有一个文本字段,我想用jquery验证。我想允许用户输入字母,数字,空格,问号,点,逗号,问号,斜线,连字符,引号和一些基本字符,当你像文字描述一样写。
感谢名单
答案 0 :(得分:0)
对此进行简单的Google搜索会将您带到http://jqueryvalidation.org/
这是一个例子:
<form class="cmxform" id="commentForm" method="get" action="">
<fieldset>
<legend>Please provide your name, email address (won't be published) and a comment</legend>
<p>
<label for="cname">Name (required, at least 2 characters)</label>
<input id="cname" name="name" minlength="2" type="text" required/>
</p>
<p>
<label for="cemail">E-Mail (required)</label>
<input id="cemail" type="email" name="email" required/>
</p>
<p>
<label for="curl">URL (optional)</label>
<input id="curl" type="url" name="url"/>
</p>
<p>
<label for="ccomment">Your comment (required)</label>
<textarea id="ccomment" name="comment" required></textarea>
</p>
<p>
<input class="submit" type="submit" value="Submit"/>
</p>
</fieldset>
</form>
<script>
$("#commentForm").validate();
</script>
阅读documentation了解详情。