添加表单验证jquery会导致以前的jquery提交函数无效

时间:2017-08-14 17:57:23

标签: php jquery

当我添加表单验证jquery时,我有一个停止按预期运行的表单。

<form class="myform" action="booking.php?token=<?php echo time(); ?>" method="get" name="f<?php echo ( $row['vehicle_id'] );?>" class="request_submit">
    <input type="hidden" name="v_id" value="<?php echo ( $row['vehicle_id'] );?>" />
    <input type="hidden" name="p_id" value="<?php echo $params['quote_location']['pickup']['location_id']; ?>" />
    <input type="hidden" name="p_val" value="<?php echo $params['quote_location']['pickup']['location_name']; ?>" />
    <input type="hidden" name="d_id" value="<?php echo $params['quote_location']['dropp']['location_id']; ?>" />
    <input type="hidden" name="d_val" value="<?php echo $params['quote_location']['dropp']['location_name']; ?>" />                     
<?php
    if (  $row['vehicle_price_mode'] == 'fixed' ):
        $v_price = $row['vehicle_price'] ;
    else:
        $v_price = ( $params['quote_price'] * $row['vehicle_price'] ) / 100 ;
    endif;

?>
<div style="padding:15px;">
    <table style="width:200px;border:0px solid black">
    <tr>
        <td align="right">
            <div class="quoteradio">
                <label><input name="q_price" type="radio" checked="checked" value="oneway|<?php echo swd_number_format(  ( $params['quote_price'] + $v_price )); ?>"> One Way: &pound;<?php echo (  swd_number_format(  $params['quote_price'] + $v_price  ) ); ?></label>
            </div>  
        </td>
    </tr>
    <tr>
        <td align="right">
            <div class="quoteradio">
                <label><input name="q_price" type="radio" value="twoway|<?php echo swd_number_format(  ( $params['quote_price'] + $v_price ) * 2 ); ?>"> Two Way: &pound;<?php echo swd_number_format(  ( $params['quote_price'] + $v_price ) * 2 ) ; ?></label>
            </div>
        </td>
    </tr>
    <tr>
        <td align="right">                      <button  type="submit" class="btn btn-primary">RESERVE </button></td>
    </tr>
    </table> 
</div>

链接到提交操作

$(".myform").submit(function(e){
    var targeted_popup_class = "popup-1";
    $('[data-popup="' + targeted_popup_class + '"]').fadeIn(350);

    e.preventDefault();
    var vehicle_id = $(this).parent().find('input[type="hidden"][name="v_id"]').val();
    $('input[name="vehicle_id"]').val(vehicle_id);
    var pickup_id = $(this).parent().find('input[type="hidden"][name="p_id"]').val();
    $('input[name="pickup_id"]').val(pickup_id);    
    var pickup_name = $(this).parent().find('input[type="hidden"][name="p_val"]').val();
    $('input[name="pickup_name"]').val(pickup_name);
    var dest_id = $(this).parent().find('input[type="hidden"][name="d_id"]').val();
    $('input[name="dest_id"]').val(dest_id);
    var dest_name = $(this).parent().find('input[type="hidden"][name="d_val"]').val();
    $('input[name="dest_name"]').val(dest_name);
    var quote_price = $(this).parent().find('input[type="radio"][name="q_price"]:checked').val();
    $('input[name="quote_price"]').val(quote_price);
});

但是当我尝试在不同表单的同一页面中包含表单验证时 我的初始提交jquery停止按预期运行

只是在我之前的jquery上面添加这个jquery税就会停止它按预期运行

      $("form[name='registration']").validate({

    }
  });

。请告诉我为什么以及如何解决这个问题。

由于

0 个答案:

没有答案