c# - How i can generate a date field in Razor based on metadata validation -


i have such code going validate in view

using system; using system.collections.generic; using system.componentmodel.dataannotations; using system.linq; using system.web; using validationproject.models;   namespace validationproject.models {     public class class1     {         [required(errormessage="this field required")]         public int one;          [required(errormessage = "this field required")]         public string two;          [datatype(datatype.date)]         public datetime date;     } } 

when try generate datetime field in razor textbox instead of date field. razor code given below:

@using validationproject.models; @model class1 @{     <script src="@url.content("~/scripts/jquery-3.0.0.js")"></script>     <script src="@url.content("~/scripts/jquery.validate.js")"></script>     <script src="@url.content("~/scripts/jquery.validate.unobtrusive.js")"></script>     <script src="~/scripts/bootstrap.js"></script>     <link href="~/content/site.css" rel="stylesheet" />     <link href="~/content/bootstrap.css" rel="stylesheet" />     <link href="~/content/bootstrap-theme.css" rel="stylesheet" />      <link href="~/content/site.css" rel="stylesheet" />     viewbag.title = "home page";      <script type="text/javascript">         $(function () {             $("input").bind("input propertychange", function () {                 if($(this).not("field-validation-error"))                 {                     $(this).addclass("success");                  }             });         });     </script>      <style type="text/css">         .input-validation-error {             border: 3px solid red;             background-color:  #fee;         }         .field-validation-error{             background:url("@url.content("~/content/1.png")") no-repeat;             font-size:15px;             background-size:25% 100%;             padding-left:60px;             padding-top:15px;             padding-bottom:15px;             color:black;         }     </style> } @{html.enableclientvalidation();} @{html.enableunobtrusivejavascript();}   @using (@html.beginform())  {      @html.editorfor(m=>m.date)      <input type="submit" />   } 

there use @html.editorfor(m=>m.date) generate date fieald in razor can't it. please help.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -