Link to home
Start Free TrialLog in
Avatar of KJACD
KJACD

asked on

JS to validate if openwysiwyg html box is not empty

I have a js validator script and would like to determine if the user fails to enter anything in an openwysiwyg HTML editor window.

Can't seem to determine what ElementID to specify...

var jobdescription = document.getElementById('jobdescription');
if (jobdescription.innerHTML.value==null)
            {
                  alert( "Please enter the Job Description!!" );
                  
                  return false;
            }


Help!!

KJACD
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

What is the jobdescription element?
If it's a TextArea it doesn't have innerHTML, you need to use:
var jobdescription = document.getElementById('jobdescription');
if (jobdescription.value==null)
            {
                  alert( "Please enter the Job Description!!" );
                  
                  return false;
            }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also

if (jobdescription.value==null)

would be better coded

if (jobdescription.value) {
  do something
}
else {
  alert("Please enter job");
}

since that would handle actual empty string too