Before submitting a JQuery form, verify that the ticket is selected and the record is deleted.

Source: Internet
Author: User

Before submitting a JQuery form, verify that the ticket is selected and the record is deleted.

First three:

 
 

These functions may be frequently required in Java Web development. Although they are simple, they are very useful. Record them here to avoid forgetting them.

1. Verify the form before submission: It is often used in the background (here is the unified verification after submission. for timely verification, please refer to my other article

Http://blog.csdn.net/jianzhonghao/article/details/52503431)

1.1 after the submit button is submitted, the corresponding path will be redirected based on the form attribute action = "path". In this case, add an onsubmit = "return check ()" attribute to the form, check () enables us to write verification functions, such:

<Form action = "path" onsubmit = "return check ()" method = "POST">

1.2 check () function is as follows (verify whether the name is filled in with the gender of the single region is selected) $ ('# notice'), just write a div and add an id attribute.

<Script type = "text/javascript"> function check () {var name = $ ('# name '). val (). trim (); var gender = $ ('input: radio [name = "gender"]: checked '). val (); if (! Name) {$ ('# notice'). text ('customer service name cannot be blank! '). Show (); return false;} else if (! Gender) {$ ('# notice'). text ('select the customer service gender! '). Show (); return false;} else {return true ;}</script> <div id = "notice" style = "font-size: 30px; color: red; margin-top: 15px; "> </div>

1.3 check whether the deletion is deleted.

<Input type = "image" src = "Path of the delete icon" title = "delete" onclick = "{if (confirm ('Are you sure you want to delete it? ') {Javascript: document: delfrom _ $ {ServerInfo. id}; return true;} return false;} "> separate write is actually if (confirm (' Are you sure you want to delete it? ') {Javascript: document: delfrom _ $ {ServerInfo. id}; return true;} return false;

The above is a summary of the validation experience on checking whether a single sheet is selected and deleting records before submitting JQuery form. I hope it will be helpful to you, if you have any questions, please leave a message and the editor will reply to you in time. Thank you very much for your support for the help House website!

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.