Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 465.4k

How to validate texbox using asp.net bootstrap error?

Mar 18 2020 3:54 AM
Hi Team
 
I am having a form with textbox and dont know how to validate the textbox, the validation has to happens when user leaves the form with empty field inserted. Message " This field is required". Here is my logic but its not validating and need some help.
  1. <div class="row">  
  2.                   <label for"Email">Email:</label>  
  3.                   <div class="input-group col-md-4 col-md-offset-2 col-sm-2 col-xs-2">  
  4.                       <div class="input-group pull-right">  
  5.                                             
  6.                           @Html.TextBoxFor(m => m.Email, new { @class = "form-control", type = "text", id = "email", autofocus = "autofocus", placeholder = "[email protected]", required = "required" })  
  7.                             
  8.                           <div class="input-group-append">  
  9.                               <div class="input-group-text">  
  10.   
  11.                               </div>  
  12.                           </div>  
  13.                       </div>  
  14.                   </div>  
  15.               </div>  
  16.   
  17. div class="input-group mb-2">  
  18.                       <div class="input-group-append">  
  19.   
  20.                       </div>  
  21.                       <div class="input-group col-md-4 col-md-offset-2 col-sm-2 col-xs-2">  
  22.                           <div class="input-group pull-right">  
  23.                                                             
  24.                               @Html.TextBoxFor(m => m.Code, new  
  25.                               {  
  26.                                   @class = "form-control",  
  27.                                   type = "text",  
  28.                              id = "postal code",  
  29.                                   autofocus = "autofocus",  
  30.                                   placeholder = "Postal / Zip Code",  
  31.                              required = "required",  
  32.                              pattern = @"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$",  
  33.                             title = "This field is required"  
  34.                               })  
  35.                                
  36.                               <div class="input-group-append">  
  37.                                   <div class="input-group-text">  
  38.   
  39.                                   </div>  
  40.                               </div>  
  41.   
  42.                           </div>  
  43.                       </div>  
  44.                   </div>  
 
 

Answers (6)