[XPages] Server validation on Dojo Richtext field

Hello,

I’m facing problems with server-side validation on Dojo Richtext field in Domino 8.5.1 XPages.

I disabled client-side validation (all properties > disableClientSideValidation = true)

I chose “xp:validateLength” validator or a custom one (xp:validator).

When richtext value doesn’t match validator, an error is displayed (correct behaviour) but the richtext field becomes empty or take a previous valid value.

Is someone facing similar problem?

Thanks in advance.

Frodon

Subject: Client Side Javascript Richtext Validation

Below is a snippet that you can use to validate richtext field using Client Side Javascript (CSJS) in Xpage.Add the following code to a CSJS of a button. I’ve commented out some alerts that I used to verify the content of the richtext field(s).

You can enable these alerts to help you troubleshoot.

There is a known issue with using CKEditor because when the page load the editor automatically adds a break tag (
) to an empty richtext field.

If you remove all the text within the richtext field, the CKEditor some how retains a   tag within the field. Therefore as a work around, I have to check for these

conditions in the code.

var txtvalue = “”;

for(var i in CKEDITOR.instances) {

//window.alert(CKEDITOR.instances[i].name); 

txtvalue = CKEDITOR.instances[i].getData();

//window.alert(CKEDITOR.instances[i].getData());

//window.alert(txtvalue.length);

// alert((txtvalue.match(/\r/) && 'CR') + ' ' + (txtvalue.match(/\n/) && 'LF'));

if ( CKEDITOR.instances[i].getData() == "" || txtvalue == "<br/>" || (txtvalue.length == 7 && txtvalue.match(/\n/)) || (txtvalue.length == 34 && txtvalue.match(/\n/))|| (txtvalue.length == 26 && txtvalue.match(/&nbsp;/)))

	{ // Check for the extra <br/> (length 7) and <p dir="ltr"><br/>&nbsp;</p> (length 34) tags being populated on IE browser.

		window.alert("This is a required field before proceeding to the next step." );

		//CKEDITOR.instances[i].focusManager.focus();

		CKEDITOR.instances[i].focus();

		// window.alert( CKEDITOR.instances[i].focusManager.hasFocus );

		return false;

	}

}

return window.confirm(“You are about to proceed to the next step. Please click to continue or to stay on the page.”);