JavaScript - client-side text-box validation using JS

Asked By Bhawana on 29-Jun-12 09:42 AM
Hi. Is it possible to insert a client side javascript for textbox control that would do the following client side validation

if user select value from dropdowllist 
Is Empty or Is Not Empty then textbox will be disable.

Super Man replied to Bhawana on 29-Jun-12 01:52 PM
var e = document.getElementById("dropDownList1");
      var strUser = e.options[e.selectedIndex].text;
      if (strUser = "") {
        document.getElementById("txtbox").disabled = true;
Lalit M replied to Bhawana on 30-Jun-12 02:39 AM
Code sample here
<script type="text/javascript">
var minimumQuestionLength = 20;

function checkQuestionBox()
    var questionLength=document.getElementById("question").value.length;

    if(questionLength < minimumQuestionLength)
     return false;
    return true;

<h1 id="myHeader">Test</h1>
<p>Question: <input type="text" id="question"/><br />
Answer: <input type="text" id="answer" onkeypress="return checkQuestionBox();"/>


Bhawana replied to Super Man on 02-Jul-12 04:26 AM
my dropdown will fill with below mention value
is exactly
Is Empty
Is Not Empty
begins with
ends with

and when user will select 
Is Empty
Is Not Empty 
 than only i have to disable the textbox,

can you help me now