When using the CKEditor control, you need to verify that the input is empty (reprint) _ Web page Editor

Source: Internet
Author: User
FCKeditor Verify that the content is empty FCKeditor js Verify the form
The original code code is as follows
Copy Code code as follows:

<script language = "JavaScript" >
<!--
function Checkform () {
if (document.form1.content.value== "") {
Alert ("Please enter the content!") ");
return false;
}
return true;
}
-->
</script>
<form name= "Form1" method= "Post" action= "" onsubmit= "return Checkform ();" >
<fck:editor id= "Content" basepath= "fckeditor/" height= ">"
</FCK:editor>
<input type= "Submit" name= "Submit" value= "Release" >
</form>

This is what we write the most often in the process of writing before submitting to verify that the content is empty!
When you press the Submit button for the first time after using the editor, the value content of the editor is entered but no value is available. We need to click the Submit button content again to get the value!
A lot of people feel puzzled about this problem! Write is to use JS to read the input domain HTML content! But this only to the full JS version of the FCKeditor only effect on the JSP version does not work! For such a state can only blame FCKeditor developers! And the code too much trouble to change its core is easy!
I have been constantly testing to get a way to solve the problem! Let's take it out and share it.
Rewrite the code as follows
Copy Code code as follows:

<script language = "JavaScript" >
<!--
function Checkform () {
SetTimeout ("Sendform ()", 50);
return false;
}
function Sendform () {
if (document.form1.content.value== "") {
Alert ("Please enter the content!") ");
Return
}
Document.form1.submit ();
}
-->
</script>
<form name= "Form1" method= "Post" action= "" onsubmit= "return Checkform ();" >
<fck:editor id= "Content" basepath= "fckeditor/" height= ">"
</FCK:editor>
<input type= "Submit" name= "Submit" value= "Release" >
</form>

The purpose of this modification is that the editor has been monitoring the onsubmit this event is to be submitted after the new content into the hidden domain content, the original too late to place the content has been executed validation events so of course not to timely content!

//==============================================

The above content is reprint, but after my actual work test, effective.

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.