0

Currectly I am creating a page which has many @Html.TextBoxFor and @Html.DropDownList. Based on the value entered in it the submit button should be enabled. I tried required but it doesn't work for me. Only if the values are entered in the fields the submit button should be enabled. Any help please?

Html code snippet:

<div class="col-md-6">
    <div class="form-group">
        <label class="control-label col-lg-4">Period:<span class="Imp">*</span></label>
        <div class="col-lg-8">
            @Html.DropDownList("Quarter", new SelectListItem[] { (new SelectListItem() { Text = "Q1", Value = "1" }), (new SelectListItem() { Text = "Q2", Value = "2" }), (new SelectListItem() { Text = "Q3", Value = "3" }), (new SelectListItem() { Text = "Q4", Value = "4" }) }, "-- Select Quarter --", new { @class = "form-control", id = "Quarter", @required = "required" })
        </div>
    </div>
</div>

<div class="col-md-6">
    <div class="form-group">
        <label class="control-label col-lg-4">ID:<span class="Imp">*</span> </label>
        <div class="col-lg-8">
            @Html.TextBoxFor(model => model.detailsConfig.ID, new { @class = "form-control", id = "ID", @required = "required" })
        </div>
    </div>
</div>

<input type="submit" id="btnSubmit" value="Submit" class="btn btn-lg btn-success" />
10
  • Try using Javascript Commented Aug 11, 2017 at 4:32
  • Welcome to the community . Please post what you have tried Commented Aug 11, 2017 at 4:41
  • are u binding this with form submit button should be inside the form Commented Aug 11, 2017 at 4:41
  • @VidiyaPrasanth Hi, I tried just the required keyword as i mentioned in the code above. Commented Aug 11, 2017 at 4:42
  • 1
    @BinoyKumar I am using "Html.BeginForm" Is this ok? Commented Aug 11, 2017 at 4:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.