Posted By

marzsman on 04/04/11


Tagged

javascript html jquery jQueryform jQueryvalidate


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jillella


Validate + submit form


 / Published in: jQuery
 

Valiodate a form with jQuery.Validate and submit it with jQuery.form

  1. $(document).ready(function(){
  2. var f = $("#signup_form").validate({
  3. rules: {
  4. firstname: "required",
  5. lastname: "required",
  6. email: {
  7. required: true,
  8. email: true
  9. },
  10. comment: {
  11. maxlength: 200
  12. }
  13. },
  14. submitHandler: function(form) {
  15. $("#signup").ajaxSubmit({
  16. success: showResponse
  17. });
  18. return false;
  19. }
  20. });
  21. function showResponse(responseText, statusText, xhr, $form) {
  22. f.resetForm();
  23. $('.msg').html('Thank you, your message was successfully sent');
  24. }
  25. });

Report this snippet  

You need to login to post a comment.