ไฟล์ index.html ใส่ฟอร์ม

<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="myscript.js"></script>
<script type="text/javascript" src="jquery.validate.min.js"></script>
<script type="text/javascript" src="jQueryPlugin.js"></script>
 </head>
<body>
<div id="info"><form  id="commentForm" action="">

<input type="text" id="hello" value="" /><br/>
<input type="text" id="studentid" name="studentid"   value="" /><input type="button" id="submit" value="get"/><input type="button" id="addstudent" value="add"/><input type="button" id="updatestudent" value="update"/><input type="button" id="deletebt" value="del"/><br/>
<input type="text" id="firstname" name="firstname"   value="" /><br/>
<input type="text" id="lastname"  name="lastname"   value="" /><br/>

<input type="button" id="getallstudent" value="get all student"/><br/>

<table id="studentlist">
</table>

<input type="submit" id="btnSubmit" value="submit validate" />
</form></div>
</body>
</html>

ไฟล์ script validate

$(document).ready(function () {
    $('#studentid').myhightlight();
    $("#info form").validate({
        rules: {
            studentid: { required: true },
            firstname: { required: true },
            lastname: { required: true }
        }
    });
    });

 

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.