Contenteditable rich text editor doesn't generate an error message when empty

Discussion in 'JavaScript' started by qwikad.com, Oct 19, 2015.

Thread Status:
Not open for further replies.
  1. #1
    My textarea doesn't generate an error message when empty. This is the textarea:

    <textarea id="wmd-input" name="<?php echo $wmd_editor['name']; ?>"><?php echo $wmd_editor['content']; ?></textarea>
    Code (markup):
    It's passed like this in the post.php page:

    
        <?php
    
        if(richTextAllowed(time())) {
        $wmd_editor = array("name"=>"addesc", "content"=>$data['addesc']);
        include("{$path_escape}editor/wmd_editor.inc.php");
        } else {
        ?>
    
        <?php
        }
        ?>
    
    
    Code (markup):
    And the error is generated by:

    
        function checkPostFields(form) {
        var msg = '';
        var value_missing = false;
        if (form.elements['addesc'].value == ''
        || form.elements['adtitle'].value == ''
        || form.elements['email'].value == ''
        <?php if ($image_verification) { ?>
        || form.elements['captcha'].value == ''
        <?php } ?>
        ) {
        msg += '<?php echo $lang['ERROR_POST_FILL_ALL']; ?>\n';
        value_missing = true;
        }
        if (!form.elements['agree'].checked) {
        msg += '<?php echo $lang['ERROR_POST_AGREE_TERMS']; ?>\n';
        }
        <?php
        if(count($xsubcatfields)) {
        foreach($xsubcatfields as $fldnum=>$fld) {
        if ($fld['REQUIRED']) {
        ?>
        if (!value_missing && !form.elements['x[<?php echo $fldnum; ?>]'].value) {
        msg = '<?php echo $lang['ERROR_POST_FILL_ALL']; ?>\n' + msg;
        value_missing = true;
        }
        <?php
        }
        }
        }
        ?>
        if (msg != '') {
        alert(msg);
        return false;
        }
        }
    
    Code (markup):
    Everything works fine when I use just the textarea, but once the rich text editor's settings applied (contenteditable) the textarea allows to post messages even if there's no content in it.
     
    Last edited: Oct 19, 2015
    qwikad.com, Oct 19, 2015 IP
  2. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,291
    Likes Received:
    1,698
    Best Answers:
    31
    Trophy Points:
    475
    #2
    Got it figured out. I got one line of code accidentally removed. Putting it back fixed it.
     
    qwikad.com, Oct 22, 2015 IP
Thread Status:
Not open for further replies.