使い方詳細
<script src="http://code.jquery.com/jquery-latest.js"></script> <!-- バリデーションJSファイル --> <script type="text/javascript" src="/js/path/jquery.validate.js"></script> <!-- message定義ファイル(日本語) --> <script language="javascript" type="text/javascript" src="/js/path/messages_ja.js"></script><script type="text/javascript"> $(document).ready(function() { $("#commentForm").validate(); }); </script>
<style type="text/css">
commentForm { width: 500px; }
commentForm label { width: 250px; }
commentForm label.error, #commentForm input.submit { margin-left: 253px; }
</style>
<form class="cmxform" id="commentForm" method="post" action=""> <fieldset> <legend>Please provide your name, email address (won't be published) and a comment</legend> <p> <label for="cname">お名前 (必須、2文字以上)</label> <input id="cname" name="name" class="required" minlength="2" /> </p> <p> <label for="cemail">E-Mail (必須、Eメールフォーマット)</label> <input id="cemail" name="email" class="required email" /> </p> <p> <label for="curl">URL (urlフォーマット)</label> <input id="curl" name="url" class="url" value="" /> </p> <p> <label for="ccomment">コメント(必須)</label> <textarea id="ccomment" name="comment" class="required"></textarea> </p> <p> <input class="submit" type="submit" value="Submit"/> </p> </fieldset> </form>
GitHub Repository