Page 1 of 1

javascript validations for Fck editor

Posted: Fri Apr 17, 2009 4:42 am
by madhurima
Hi,
I'm working on FCK editor.I want validations for Fck editor.Actual task is,if the user submits the form with empty data in the Fck editor body , i have to give an alert to user that not to submit the form without any data.
Upto this i got the validation.If i'm entering any spaces in the Fck editor body,alert is not coming..
I want validation for, if user enters any space (without any type of data) in the fck body.....
alert have to come.also if any user enters NEWLINE(i.e if user press on ENTER BUTTON without inserting any type of data ) without textdata alert have to come....
Can any one pls help me to do this validation for fck editor....
Pls give reply as soon as possible.

Thank u in advance,
madhu :)

Re: javascript validations for Fck editor

Posted: Sun Apr 19, 2009 5:37 am
by novice4eva

Code: Select all

 
regex = /^(\s)*$/;
if(fckEditorFieldName.value.match(regex))
alert('is empty');
else
alert('is not empty');
 
Haven't checked for "enter" but this might work.

Re: javascript validations for Fck editor

Posted: Sun Apr 19, 2009 10:11 pm
by madhurima
Hi novice4eva,

the code which u replied is not working for me....i'm pasting my code here.
var s = FCKeditorAPI.GetInstance('title') ;
var s1=s.GetXHTML();
regex = /^(\s)*$/;
if(s.GetXHTML()==""||s.GetXHTML()==null || title.value.match(regex))
{
alert("Enter Fck value");
return false;

}


if any mistakes in the above,pls let me know...
i want validations for both space and enter mode.
reply me as early as possible.


Thank u in advance,
madhu.

Re: javascript validations for Fck editor

Posted: Wed Apr 22, 2009 12:42 am
by novice4eva
sorry madhurima for late reply, the code i have given to you worked perfectly for textarea, so i believe it should be same for the editor too!!
Could you tell us what you get when you alert the value(when the field is empty)??

EDIT:
I think it should be:

Code: Select all

 
var s = FCKeditorAPI.GetInstance('title') ;
var s1=s.GetXHTML();
regex = /^(\s)*$/;
if(s.GetXHTML()==""||s.GetXHTML()==null || s1.match(regex) || s1.length==0){
...
 

Re: javascript validations for Fck editor

Posted: Wed Apr 22, 2009 1:20 am
by irshad_sheikh
function validate()
{
var content_value = FCKeditorAPI.GetInstance('content').GetXHTML(true);
if(content_value == "")
{
alert("Please enter Content.");
return false;
}

content is the name of Fck editor.

It will work. :)

Re: javascript validations for Fck editor

Posted: Wed Apr 22, 2009 4:28 am
by madhurima
Hi,
my actual requirement in my project is,
we want a editor to post comments on page.I used Fckeditor for this.Also we need validations for that.

a)If any user tried to submit the form without entering the values in the body of Fck editor, i want to give a alert to enter message in the body(condiion is message should be less than 250 characters).
b) second thing is that,if any user entered empty lines means if user entered spaces,
then also we need to alert the user that enter some message
c)lastly,if any user entered multiple of empty lines(ex:if user clicked on enter button continously in the body of Editor) then also we need to alert.

I got validation if any user tried to submit the form without entering any message in body.
i'm not getting that how to write the code to limit the body of editor to 250 characters.
I need a code which will be applicable to above mentioned points.

Also one more main thing is......Bold,italic and underline are not working properly in any browser.....
can anyone pls help me in doing this task.

Thanks in advance,
madhu.

On Tinymce editor

Posted: Wed Apr 22, 2009 4:54 am
by syamala
HI,
I need validations for tinymce editor.my requirement is also same as post related to fckeditor.
here are my requirements,can anyone pls have a look on this and send me reply if knows.
a)I want validations for tinymce editor.Validation like not to submit without any content in the body of tinymce editor
b)I need to display the tinymce editor multiple of times in a single page in a ajax page.

Can anyone help me for this.

Thank u inadvance,
syamala

any other editors

Posted: Wed Apr 22, 2009 5:00 am
by syamala
Hi,
anybody know editors which are compatible to all browsers other than Fckeditor & Tinymce editor.....???????

Give me reply as early as possible.

Thank u inadvance,
syamala