Marius Vasile

Marius Vasile

  • 1.1k
  • 1.1k
  • 26.7k

asp.net core validate a bool value

Mar 5 2021 7:54 AM
I have a bool value for which I cannot use default validation at Model stage because in one form it can be false but in another it has to be true. I want that if is true to allow post if not, not
 
  1. <div class="col-md-4 text-center">  
  2.                         <label class="form-control text-white pl-2" style="background-color:firebrick;"> Equipment Available?</label>  
  3.                         <div class="d-flex justify-content-center mt-3">  
  4.                             <input asp-for="WOPlanner.ToolsAvailable" type="checkbox" data-width="200" data-toggle="toggle" data-on="Yes" data-off="No" data-onstyle="success" data-offstyle="primary" value="@Model.WOPlanner.ToolsAvailable"/>  
  5.                         </div>  
  6.                     </div>  
the value I take is from the table which allows false but it should not allow post through
 
  1. <div class="row no-gutters border border-0 ">  
  2.             <div class="col-md-3 mt-2">  
  3.                 <button asp-page-handler="WOSchedule" asp-route-womainid="@Model.WOMainID" class="col-md-12 btn btn-link font-weight-bold" style="border-color:firebrick; background-color:lightgray; color:firebrick" type="submit">Submit</button>  
  4.             </div>  
  5.         </div>  
 

Answers (13)