Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Rich text validation

Community Beginner ,
Aug 09, 2010 Aug 09, 2010

Hi there,

Is there any way to validate the input in the rich text area before submission? Let's say I have a form with rich text enabled and user just copy/pastes something off net. It looks all fine, but at the time of submission it doesn't validate and gives coldfusion error report. However, that is already too late as half of the form has been already submitted and some tables updated/records created which makes a big mess. So is there any way to validate html code inside the text area?

cheers,

Simon

938
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 09, 2010 Aug 09, 2010
Is there any way to validate the input in the rich text area before submission?

What rule(s) are you trying to enforce with your validation?

gives coldfusion error report

What is the error message?

but at the time of submission it doesn't validate and gives coldfusion error report. However, that is already too late as half of the form has been already submitted and some tables updated/records created which makes a big mess.

You should validate the input on the server-side before doing any database changes.

It will be easier to help you if you can provide your code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 09, 2010 Aug 09, 2010

Hi Bob,

When copied from the net text sometimes has unclosed tags such as </div> or </span> etc. If left it causes the error. Therefore I wanted to know whether there is some function or any other method to check html code inside rich text area on submission and if not validated display error message.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 09, 2010 Aug 09, 2010

If you are requiring the user to input valid xhtml you might use the IsXml function to determine if the input is XML.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 09, 2010 Aug 09, 2010

Thanks mate. Is there any way to do this in onclick event? let's say I would create button on the side of the form which would validate it once clicked. But the isXML is coldfusion function and onclick is javascript. any way to mash these together?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 09, 2010 Aug 09, 2010

You could use AJAX to submit the textarea contents to the server to use IsXML, to validate on the client side you would need a Javascript library that can parse XML.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 09, 2010 Aug 09, 2010

Once you have figured out the code, you'll have to figure out a way to make it useable.  For example, if someone copies half a paragraph from somewhere, are you really going to refuse the submission?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 09, 2010 Aug 09, 2010
LATEST

Dan, this rich text form is for administrators use only and is a part of the code to create a new personalised profile. Therefore rich form is very helpful, but has to be done correctly in order to display page without any errors. Besides it doesn't let me run through the submission code as coldfusion hangs on some error related to this badly formatted text.

Well, i'll try to use AJAX to perform isXML. Hopefully that will sort it out for me.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources