How to validate the range for number of members can attend while booking

I am working on a project in which I want to validate the number of members can attend while booking the auditorium. the validation should be applied on numeric textbox value increment  if it is not touched or 0 then it should show the validation message on click of request button.

1 Reply 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team February 17, 2021 01:58 PM UTC

Hi Ishan, 

Greetings from Syncfusion support. 

We have prepared sample based on your requirement using Required and MaxLength validation. Please find the sample below. 

@using (Html.BeginForm()) 
{ 
    @Html.ValidationSummary(true) 
    <div class="col-lg-12 control-section"> 
        <div id="wrapper"> 
            @Html.EJS().NumericTextBoxFor(model => model.value).Width("200px").Render() 
            <div> 
                @Html.ValidationMessageFor(model => model.value) 
            </div> 
            <div id="submitbutton"> 
                @Html.EJS().Button("btn").Content("Post").Render() 
            </div> 
        </div> 
    </div> 
} 

[Controller] 
public class NumericValue 
    { 
        [Required] 
        [Range(1, 10)] 
        public int value { get; set; } 
    } 
 
    public class HomeController : Controller 
    { 
        public ActionResult Index() 
        { 
            NumericValue val = new NumericValue(); 
            val.value = 10; 
            return View(val); 
        } 
        [HttpPost] 
        public ActionResult Index(NumericValue model) 
        { 
            NumericValue val = new NumericValue(); 
            val.value = model.value; 
            return View(val); 
        } 


Please get back us if you need further assistance. 

Regards, 
Ponmani M 


Marked as answer
Loader.
Up arrow icon