Both xheditor and validate are excellent jQuery plug-ins, but the combination of the two is good, if the initialization is not in the wrong order, there will be some subtle results. I used both plug-ins when I made a text submission page, one for the rich text editor, one for verifying that the user was filled in, and my initialization code was as follows:
Copy Code code as follows:
$ ("#form1"). Validate ({
Rules: {
Body: "Required"
},
Messages: {
Body: "Please fill in the text"
}
});
var editor = $ ("#Body"). Xheditor (True, {
Tools: "Simple"
});
However, in the submission, although the content has been filled out, the first time you click the Submit button will still show "please fill in the body", the second click on the Submit button to be really submitted, this phenomenon let me baffled, what exactly is the problem?
Because there are several pages in the current project that use these two plug-ins, and one of the pages is normal to submit, so I carefully compared the normal and problematic page similarities and differences, found that the order of initialization is not the same. In the normal submission of the page first initialized Xheditor, and then initialize the validate, and the problem of the page is the opposite, the original is so! Problem to this also use solves, as long as reverses the initialization order of these two plug-ins, let Xheditor before validate initialize, can avoid "two submit" the problem occurs.
I hope this article is helpful to you.
CKEditor also have this problem, my solution is to get editor content into the textarea in the good.