Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Jquery Form



<html>1
<head>
<title>JQuery Form Example</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
    <script type="text/javascript">
$(document).ready(function(){
$("#myform").validate( {
debug: false,
rules: {
name: "required",
email: {
required: true,
email: true
}
},
messages: {
name: "Please let us know who you are.",
email: "A valid email will help us get in touch with you.",
},
submitHandler: function(form) {
// do other stuff for a valid form
$.post('process.php', $("#myform").serialize(), function(data) {
$('#results').html(data);
});
}
});
} );
</script>
<style>
label.error { width: 250px; display: inline; color: red;}
</style>
</head>
<body>
<form name="myform" id="myform" action="" method="POST">
    <label for="name" id="name_label">Name</label>
    <input type="text" name="name" id="name" size="30" value=""/>
<br>
    <label for="email" id="email_label">Email</label>
    <input type="text" name="email" id="email" size="30" value=""/>
<br>
<input type="submit" name="submit" value="Submit">
</form>
<!-- We will output the results from process.php here -->
<div id="results"><div>
</body>
</html>


This post first appeared on What Is AJAX.?, please read the originial post: here

Share the post

Jquery Form

×

Subscribe to What Is Ajax.?

Get updates delivered right to your inbox!

Thank you for your subscription

×