Form submits but by passing the form validation when button.click is used

Posted by Cuty Pie on Stack Overflow See other posts from Stack Overflow or by Cuty Pie
Published on 2012-11-20T10:56:07Z Indexed on 2012/11/20 11:01 UTC
Read the original article Hit count: 220

Filed under:
|

I am using form validation plugin as well as html5 attribute=recquired with input type=button or submit and fancybox.when button is clicked ,both validation proceedures work(notification of empty inputs appeare),but instead of this notification ,form is submitted.

If I dont use button.click function but use simple submit.then validation works perfectly

plugin==http://validatious.org/

javascript function

   $(document).ready(function() {

    $('#send').click(function() {

    $(this).attr("value", 'Applying...');


    var id = getParam('ID');
    $.ajax({
        type:'POST',
        url:"send.php",



        data:{option:'catapply', tittle:$('#tittle').val(), aud:aud, con:con, adv:adv, mid:$('#mid').val(), aud2:aud, cid:$('#cid').val(), scid:$('#scname option[selected="saa"]').val(), gtt:$('input[name=gt]:radio:checked').val(), sr:$(":input").serialize() + '&aud=' + aud},

        success:function(jd) {
            $('#' + id).fadeOut("fast", function() {
                $(this).before("<strong>Success! Your form has been submitted, thanks :)</strong>");
                setTimeout("$.fancybox.close()", 1000);
            });
        }
    });
  });
 });

AND Html is here

<form id="form2" class="validate" style="display: none" >

        <input  type='submit'  value='Apply' id="send" class="sendaf validate_any" name="jobforming"/>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html