即使字段填充红宝石后,表单也不会提交

时间:2016-05-12 06:12:19

标签: javascript jquery ruby-on-rails ruby

问题是我正在尝试提交表单,但表单未提交并显示通知填写所有详细信息。早些时候,当我没有与ruby表单标记集成时,它与正则表达式验证工作正常。以下是html格式代码:

<%= form_tag({:controller => "home", :action => "update_order_details"}, :method => "post", :class => "order_details_form") do %>
    <%= hidden_field_tag 'user_id',nil, value: current_user %>
    <%= hidden_field_tag 'order_id', @order.id %>
    <%= hidden_field_tag 'txnid', @order.txnid %>
        <div class="contact_details">
            <div class="payment_details">
                <p>SHARE YOUR CONTACT DETAILS</p>
                <div class="form-group">
                    <input type="text" class="input_name" id="fullName" pattern="^([a-zA-Z]+\s)*[a-zA-Z]+$" title="Type only characters" name="name"  placeholder="FULL NAME" required/>
                </div>
                <div class="form-group">
                    <input type="email" class="input_name" id="email" title="Eg: some@mail.com" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" name="email" placeholder="EMAIL ADDRESS" required/>
                </div>
                <div class="form-group">
                    <input type="text" class="input_name" id="mobileNumber" maxlength="10" pattern="^(\+\d{1,3}[- ]?)?\d{10}$" title="Enter 10 digit Valid Mobile Number" name="mobile" placeholder="MOBILE NUMBER" required/>
                </div>
            </div>
        </div>  

        <div class="terms_wrap">
            <div class="checkbox">
                <label>
                    <input type="checkbox" class="terms_condition" name="terms_condition" value="">
                </label>
            </div>
        </div>  
        <button type="submit" class="btn btn-primary pay_btn" style="display:none;">PAY</button>
<% end %> 

JS CODE:

$('.pay_btn').on('click', function(e){
    e.stopPropagation();
    e.preventDefault();


        $('.payment_details input').keyup(function() {
            var empty = false;
            $('.payment_details input').each(function() {
                if ($(this).val() == '') {
                    empty = true;
                }
            });
            if (empty) {
                $('.actions input').attr('disabled', true);
            } else {
                $('.actions input').attr('disabled', false);
            }
        });
        $.ajax({
            type: 'post',
            url: '/update_order_details',
            data: $('.order_details_form input').serialize()
        }).complete(function (data, textStatus, jqXHR) {
            if (data.status === 200 ){
                $('.result').html(data.responseText);
                $('.payumoney').submit();
                setNotification('success', 'Proceeding To Payment!');
            }
            else{
                setNotification('error', 'Fill all details');
            }
        })
    // }
})

JS Code For Checkbox:
$("input[name='terms_condition']").on("change", function(){
        var isChecked = $(this).prop("checked"); 
        if(isChecked){
            $(".pay_btn").show(); 
        } else {
            $(".pay_btn").hide(); 
        }
    });

有谁能告诉我哪里出错了。

0 个答案:

没有答案