jquery Submit () cannot submit a form solution

Source: Internet
Author: User

I need to add a confirmation prompt when I write the form today, so I did not use the submit button to submit it, and then we changed the question by using JQ's submit ().

<formclass= "Form-horizontal m-t"Method= "POST"Action= "@Url. Action ("Edit ")" ID= "form">        <Divclass= "Row">            <Divclass= "Col-sm-12">                <Divclass= "Ibox float-e-margins">                    <Divclass= "Ibox-title">                        <h5>Add to</h5>                    </Div>                    <Divclass= "Ibox-content">                        <Divclass= "Form-group">                            <labelclass= "Col-sm-3 Control-label">Start time:</label>                            <Divclass= "Col-sm-8">                                <span>@ (model.annualrate_begindate?. ToString ("Yyyy-mm-dd"))</span>                            </Div>                        </Div>                        <Divclass= "Form-group">                            <labelclass= "Col-sm-3 Control-label">End Time:</label>                            <Divclass= "Col-sm-8">                                <inputtype= "text"class= "Form-control"name= "Annualrate_enddate"ID= "Annualrate_enddate"onclick= "Laydate ({istime:false, format: ' Yyyy-mm-dd '})"value= "@Model. Annualrate_enddate.tostring ("yyyy-mm-dd ")" Required>                            </Div>                        </Div>                        <Divclass= "Form-group">                            <labelclass= "Col-sm-3 Control-label">Annual Interest%:</label>                            <Divclass= "Col-sm-8">                                <inputtype= "Number"Step= "0.01"class= "Form-control"ID= "Annualrate_rate"name= "Annualrate_rate"value= "@Model. Annualrate_rate. ToString ("#0. ")" Required>                            </Div>                        </Div>                        <Divclass= "Form-group">                            <Divclass= "Col-sm-4 col-sm-offset-2">                                <Buttonclass= "btn btn-lg btn-primary"ID= "Submit_btn"type= "button">Submit</Button>                                <aclass= "btn btn-lg btn-white"href= "@Url. Action ("Index ")">Cancel</a>                            </Div>                        </Div>                    </Div>                </Div>            </Div>        </Div>    </form>

1<script type= "Text/javascript" >2$(function () {3$ ("#submit"). Click (function () {4             varstart = ' @ (model.annualrate_begindate?. ToString ("Yyyy-mm-dd")) ';5             varEnd = $ ("#annualRate_endDate"). Val ();6             varval = $ ("#annualRate_rate"). Val ();7Layer.confirm (' Please confirm that the information you have filled is correct? <br/> start time: ' + start + ' <br/> end time: ' + END + ' <br/> annual interest Rate: ' + val, {icon:3, title: ' Hint '},function(index) {8$ ("#form"). Submit ();9 layer.close (index);Ten             }); One         }); A     }) -</script>

Click the Submit button to confirm the prompt, but the confirmation will not respond.

But the type of the button is changed to submit but can be submitted

So on the jquery API to find the reason, see the following text immediately understand:

Additional Notes:

Forms and their child elements should does use the input names or IDs that conflict with properties of a form, such submit as, c1/>, or method . Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see domlint.

It probably means that the form and its child elements should not use the attributes of a form as name or ID names, such as submit, length, and method, etc., otherwise there will be conflicts, which can be caused by name collisions.

It turns out that the button ID is set to submit

The next step is to change the ID so it's no problem.

jquery Submit () cannot submit a form solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.