javascript validation for text editor not working

Discussion in 'JavaScript' started by deepu1023, Aug 10, 2010.

  1. #1
    my code
    <html>
    </head>
    <script language="javascript" type="text/javascript" src="../AT_STD_WYS_v1.5/wysiwyg.js">
    function chkvaild()
    {
    var d=document.formname;

    if(d.content.value=="")
    {
    alert('Enter the Text!');
    d.content.focus();
    return false;
    }
    return true;
    }
    </script>
    </head>
    <body>
    <form method="post" action="sending_sms.php" name="formname" onSubmit="return chkvaild()" style="padding-top:5px;" enctype="multipart/form-data">

    <textarea name="content" id="content" style="width:250px; height:90px;"></textarea>
    <script language="javascript1.2">
    generate_wysiwyg('content', '500', '200'); </script>
    </body>
    </html>

    this is my code validation not working if i remove text editor its working
    can anyone tell me how to slove this prblm
     
    deepu1023, Aug 10, 2010 IP
  2. prasanthmj

    prasanthmj Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #2
    The text editor must be adding some content (like some blank spaces). Try throwing an alert box with the content. Trim the blank spaces before validation.
    Here is some code for trimming the blank space:
    
    function str_trim(strIn)
    {
        return strIn.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
    }
    
    Code (markup):
     
    prasanthmj, Aug 11, 2010 IP