$(document).ready(function() { $("#contact-form").validate({ rules: { fullName: { //input name: fullName required: true, //required boolean: true/false minlength: 5, }, email: { //input name: email required: true, //required boolean: true/false email: true //required boolean: true/false }, subject: { //input name: subject required: true, //required boolean: true/false minlength: 5 }, message: { //input name: message required: true, minlength: 1 } }, messages: { //messages to appear on error fullName: { required: "Please put your full name.", minlength: "C'mon full name please." }, email: "Enter a valid email.", subject: { required: "Whats the topic?", minlength: "" }, message: { required: "What did you want to say?", minlength: "Please complete your thoughts, then submit." } }, submitHandler: function(form) { $(form).ajaxSubmit({ url: "echo/html", type: "GET", success: function() { alert('inside'); $('#contact-form').hide(); $('#sent').show(); } }); } }); })
<div id="contact" class="corner-5"> <a class="handle" href="http://lesson8.blogspot.in/">Contact</a> <form id="contact-form" method="post"> <input class="input required error" type="text" name="fullName" title="What shall I call you?" placeholder="Name"/> <input class="input required error" type="text" name="email" title="[email protected]" placeholder="Email Address"/> <input class="input required error" type="text" name="subject" title="Topic of conversation" placeholder="Title"/> <textarea class="txt-input required error" name="message" rows="6" placeholder="Message"></textarea> <input class="submit" type="submit" name="submit" value="submit"/> </form> <div id="sent">Sucess</div> </div>
#contact{ padding: 20px; width: 250px; background: #FFF; border: 1px solid #29216d; position: static; margin-top:20px; margin-left:20px; position: fixed; z-index: 200; -moz-box-shadow: inset 0 0 10px #000000; -webkit-box-shadow: inset 0 0 10px #000000; box-shadow: inset 0 0 10px #000000; } .txt-input, .input{ color:#aaa; margin: 3px 0; font-family: Helvetica; font-size: 11px; } .txt-input{ width: 250px; } .input{ width: 200px; } .txt-input:focus, .input:focus{ color:#000; } label.error{ float: left; font-size: 10px; font-weight: bold; color:red; } .submit{ margin-top:20px; display: block; padding:5px; } #sent{ display:none; }