Wednesday, 23 October 2019

MVC Client side validation using jquery



///////////////////Add Namespace-

      using System.Collections.Generic;

      using System.ComponentModel.DataAnnotations;

//////////////////// Add models with required

   public class Login
    {
        [Required]
        public string UserID { get; set; }
        [Required]
        public string Password { get; set; }

    }


//////////////////// web.config file configuration


<appSettings>
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>


////////////////////  Add J-query Libraries Inside script folder

    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
    <script src="~/Scripts/jquery.validate.js"></script>

    <script src="~/Scripts/jquery.validate.unobtrusive.js"></script


////////////////////  Call J-query Libraries on page .cshtml

    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
    <script src="~/Scripts/jquery.validate.js"></script>

    <script src="~/Scripts/jquery.validate.unobtrusive.js"></script


////////////////////  Call J-query Libraries page on top of the page

@{
    Layout = null;
    Html.EnableClientValidation(true);
}







No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...