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
KJACDAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Technology SpecialistCommented:
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

0
Ray PaseurCommented:
If you use the HTML5 doctype, you can use the "required" attribute.  It seems to work well with text and textarea input controls.  Have not tested others.
http://www.laprbass.com/RAY_temp_kjacd.php

This is wrapped in PHP so we can see what comes through in the POST request, but you could easily extract just the HTML document.

<?php // RAY_temp_kjacd.php
ini_set('display_errors', TRUE);
error_reporting(E_ALL);
if (!empty($_POST)) var_dump($_POST);

// CREATE OUR WEB PAGE IN HTML5 FORMAT
$htm = <<<HTML5
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<title>HTML5 Page in UTF-8 Encoding</title>
</head>
<body>

<form method="post">
<input type="text" name="jobdescription" required />
<input type="submit" />
</form>

</body>
</html>
HTML5;

// RENDER THE WEB PAGE
echo $htm;

Open in new window

HTH, ~Ray
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Michel PlungjanIT ExpertCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.