asp.net control validation fckeditor_ practical tips

Source: Internet
Author: User
After looking up the information on the Internet, it appears that it is a problem of its own, the original text is as follows:

with ASP.net, I need to submit twice if using the RequiredFieldValidator in a FCKeditor instance
FCKeditor won't work properly with the Required Field Validator the ' enableclientscript ' property of the Validator is set to "true" (default). Due to a limitation into the default validation system, you must set it to "false".

If you are want to do client side validation, your must use a Custom Validator instead and provide the appropriate validation F Unction, using the FCKeditor JavaScript API.

The translation is not good, you can read it well:
Q: Why do I need to submit two times when using ASP.net's RequiredFieldValidator
A: When RequiredFieldValidator's EnableClientScript property is set to True, FCKeditor does not support RequiredFieldValidator very well, in order to remove this limitation, You have to set this property to False. If you want to use client-side authentication, you must use custom validator to make a non-empty validation to replace RequiredFieldValidator, where you can use FCKeditor JavaScript API can be.

After reading this article, I went to the documentation for the FCKeditor JavaScript API and found that it provided some properties and methods for the invocation of client JavaScript, and then wrote a JavaScript script to complete the validation with the answer.

Detailed workaround: Add JavaScript Script first:
Copy Code code as follows:

Script language= "javascript" type= "Text/javascript" >
var oediter;
function customvalidate (source, arguments)
{
var value = oediter.getxhtml (true);
if (value== "")
{
Arguments. IsValid = false;
}
Else
{
Arguments. IsValid = true;
}
}
function Fckeditor_oncomplete (editorinstance)
{
Oediter = editorinstance;
}
</script>

' Then add CustomValidator, set clientvalidationfunction= ' Customvalidate ', and be careful not to forget validateemptytext= ' True ', otherwise it won't work!

In this way, try again, OK, can be submitted directly at one time, there will not be a bug submitted two times

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.