locked
How can I Conditional disabling the textbox depends the value of the other column RRS feed

  • Question

  • User2038750770 posted

    <div>I am trying to make to conditionally disable a textbox depends the value of other column I have the model class. I want to make the textbox  PositionDetails  have to be disabled when  there is no value  in the column Position. Please help how to disable the textbox 

    <div class="input-group">
              <div class="input-group-addon">
              <select asp-for="Position" name='isposition' >
              <option Value='Y'>Yes</option>
              <option Value='N'>N</option>
              </select>
              </div>
            <input type="text" class="form-control" asp-for="PositionDetails" data-role="text" name='position' id='position' disabled />
    </div>


    </div>

    Sunday, March 8, 2020 7:43 AM

Answers

  • User2038750770 posted

    I  solved  this problem by  the code given below

    $('select[name="isposition"]').change(function () {
    $('input[name="position"]').prop('disabled', this.value == "Y" ? false : true);
    if (this.value=='N')
    {
    $('#position').val(""); 
    }
    });



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 8, 2020 11:23 AM