Both xheditor and validate are excellent jquery plug-ins, but they are combined. If the initialization order is incorrect, some subtle results will appear. I used these two plug-ins at the same time when I made a text submission page. One is used to display the rich text editor, the other is used to verify whether the user entered the content, and my Initialization CodeAs follows:
Copy codeThe Code is as follows: $ ("# form1"). Validate ({
Rules :{
Body: "required"
},
Messages :{
Body: "enter the body"
}
});
VaR editor = $ ("# Body"). xheditor (true ,{
Tools: "simple"
});
However, even if the content has been filled in, the "please fill in the body" is still displayed when you click the submit button for the first time. The second time you click the submit button, it will actually be submitted, I was puzzled by this phenomenon. What is the problem?
Because these two plug-ins are used on multiple pages in the current project, and one of the pages is normal when submitted, I carefully compared the normal and problematic pages, the initialization sequence is different. Initialize the xheditor on the page that can be submitted normally, and then initialize the validate. The opposite is true for the problematic page! This problem can be solved as well. You only need to reverse the initialization sequence of the two plug-ins so that xheditor can initialize the plug-ins before validate to avoid the issue of "Two submissions.
I hope this article will help you.
Ckeditor also has this problem. The solution is to get the content in the editor and put it in textarea.