javascript validations for Fck editor

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
madhurima
Forum Newbie
Posts: 15
Joined: Thu Mar 12, 2009 4:55 am

javascript validations for Fck editor

Post 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 :)
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: javascript validations for Fck editor

Post 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.
madhurima
Forum Newbie
Posts: 15
Joined: Thu Mar 12, 2009 4:55 am

Re: javascript validations for Fck editor

Post 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.
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: javascript validations for Fck editor

Post 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){
...
 
Last edited by novice4eva on Tue Apr 28, 2009 12:38 am, edited 2 times in total.
irshad_sheikh
Forum Newbie
Posts: 7
Joined: Mon Jan 19, 2009 1:57 am

Re: javascript validations for Fck editor

Post 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. :)
madhurima
Forum Newbie
Posts: 15
Joined: Thu Mar 12, 2009 4:55 am

Re: javascript validations for Fck editor

Post 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.
syamala
Forum Newbie
Posts: 3
Joined: Wed Apr 22, 2009 4:36 am

On Tinymce editor

Post 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
syamala
Forum Newbie
Posts: 3
Joined: Wed Apr 22, 2009 4:36 am

any other editors

Post 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
Post Reply