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