Asp.net control validation FCKeditor

Source: Internet
Author: User

After searching for information on the Internet, it seems that it is a problem. The original Article is as follows:

With ASP. NET, I need to submit twice when using the requiredfieldvalidator IN A FCKeditor instance
FCKeditor will not work properly with the required field validator when the "enableclientscript" property of the validator is set to "true" (default ). due to a limitation in the default validation system, you must set it to "false ".

If you want to do client side validation, you must use a custom validator instead and provide the appropriate validation function, using the FCKeditor javascript API.

The translation is as follows (the translation is not good and everyone can understand it ):
Q: Why do I need to submit it twice when using ASP. NET requiredfieldvalidator?
A: When the enableclientscript attribute of requiredfieldvalidator is set to true, FCKeditor does not support requiredfieldvalidator. To remove this restriction, you must set this attribute to false. If you want to use client verification, you must use M validator to create a non-empty verification to replace requiredfieldvalidator, where you can use the FCKeditor javascript API.

Read this articleArticleI went to the FCKeditor javascript API documentation and found that it provides some attributes and methods for client JavaScript calls, according to the above answer, I wrote a Javascript script to complete the verification.

Detailed solution: First add a Javascript script:CopyCodeThe Code is 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 and set clientvalidationfunction = "customvalidate". Do not forget validateemptytext = "true", otherwise it will not work!

In this way, try again. OK, you can submit it directly once, and there will be no bugs submitted twice.

Related Article

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.