I am unable to use form validation correctly. Here's the function I use:
function check_empty(items)
{
l = items.length;
for (i = 0; i < l; i++)
{
if (document.forms[0].elements[items[i][0]].value == '')
{
alert(items[i][1] + ' field cannot be empty.');
return false;
}
}
return true;
}
<form method="post" ... onsubmit="return check_empty([['head', 'Headline'], ['fck', 'Body']])">
...
</form>
Firefox displays alert even if FCKeditor textarea is filled in.
Empty textarea is submitted without alert even when data from the db put into the FCKeditor textarea is deleted in the editor (thus it is empty and should trigger alert). Since I have FCKeditor integrated using PHP, for putting data into FCKeditor textarea I use this method:
$oFCKeditor->Value = $mydata;
As mentioned above, $mydata comes from db.
I'd be glad if anyone could tell me if there's a way to use form validation when form's textarea is replaced with FCKeditor. So far I haven't found a way to do the same.
function check_empty(items)
{
l = items.length;
for (i = 0; i < l; i++)
{
if (document.forms[0].elements[items[i][0]].value == '')
{
alert(items[i][1] + ' field cannot be empty.');
return false;
}
}
return true;
}
<form method="post" ... onsubmit="return check_empty([['head', 'Headline'], ['fck', 'Body']])">
...
</form>
Firefox displays alert even if FCKeditor textarea is filled in.
Empty textarea is submitted without alert even when data from the db put into the FCKeditor textarea is deleted in the editor (thus it is empty and should trigger alert). Since I have FCKeditor integrated using PHP, for putting data into FCKeditor textarea I use this method:
$oFCKeditor->Value = $mydata;
As mentioned above, $mydata comes from db.
I'd be glad if anyone could tell me if there's a way to use form validation when form's textarea is replaced with FCKeditor. So far I haven't found a way to do the same.
RE: Impossible Form Validation
You can update the textarea using javascript in the beginning of your submit function like this:
function check_empty(items)
{
// grab fckEditor valoe
fckEditor1val = FCKeditorAPI.__Instances['fckEditor Name'].GetHTML();
// set textarea value for validation
document.getElementById("textarea id").value = fckEditor1val;
l = items.length;
for (i = 0; i < l; i++)
{
if (document.forms[0].elements[items[i][0]].value == '')
{
alert(items[i][1] + ' field cannot be empty.');
return false;
}
}
return true;
}
Hope this helps