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.