Before submitting a form, JQuery modifies the original submitted value. jqueryfont

Source: Internet
Author: User

Before submitting a form, JQuery modifies the original submitted value. jqueryfont

When I was working on a company project today, I encountered a problem:

We hope that when searching for the second-level column, we can determine whether the user has added the unique Keywords of this column (for example, "tutorial"), because we are a full-site search. If no keyword is added, there will be a lot of things to be searched out, so we just want to find all the things related to the tutorials in this topic, so we have a little bit of attention, make minor changes to the search keywords. The Code is as follows:

Copy codeThe Code is as follows:
$ ('# Search-form'). submit (function (){
// Retrieve the keyword
$ Keyword = $ ('# keyword ');
 
// Determine whether the keyword "tutorial" is included
If ($ keyword. val (). indexOf ('tutorial ') <0)
{
$ Keyword. val ($ keyword. val () + '');
}
});

You can use this code. When we search for a CSS tutorial, the program will determine that the package does not contain any, and will not splice the word "tutorial" With keyword, when we search for CSS, We splice it into a "CSS tutorial" to search.

OK. I hope I can help you.

Articles you may be interested in:
  • Jquery implements Simple Form Verification
  • Simple Example of jquery Form Verification
  • JQuery implements form forms based on ajax without refreshing new submission methods
  • JQuery implements the batch judgment of non-empty text boxes in a form (two methods)
  • JQuery uses $. ajax to submit a complete example of a form
  • Share a form submission instance in EasyUI of jquery plug-in
  • Example Description: jQuery Form Verification plug-in validate
  • In-depth learning about jQuery Validate form verification (2)
  • JQuery form plug-in formDdata Parameter validation form and submit after verification
  • FormSerialize, fieldSerialize, fieldValue, resetForm, clearForm, and clearFields for jQuery Form submission plug-ins
  • Get content from jquery form and bind data
  • Use JQuery to implement smart Form Verification

Related Article

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.