0

it is such that I have to add some data-val used to birthday indicating when to have fødelsedag. Have could check add it to plain html but mvc html part, I have tried to do like this.

it causes problems at the two Using data-* and I can not pardon to enter it.

 @Html.TextBox("txtFornavn", null, new
 {
  @class = "form-control input-lg",
  placeholder = "Fornavn",
  data-val="true",
  data-val-required="Date is required",
  type = "date"
 })

Normally, my html part like this.

<input type="date" class="form-control input-lg" data-val="true" data-val-required="Date is required">

I have written it here, and it works just fine out problems.¨

 @Html.TextBox("txtFornavn", null, new
  {
   @class = "form-control input-lg",
   placeholder = "Fornavn",
   type = "date"
  })

i have try its here:

Html5 data-* with asp.net mvc TextboxFor html attributes

Community
  • 1
  • 1
Jesper
  • 5
  • 3

2 Answers2

0

the link posted gave you your answer. You have to use underscore _ if you want to use dashes in an attribute name

 @Html.TextBox("txtFornavn", null, new
 {
  @class = "form-control input-lg",
  placeholder = "Fornavn",
  data_val="true",
  data_val_required="Date is required",
  type = "date"
 })

did you try that?

JamieD77
  • 13,796
  • 1
  • 17
  • 27
  • Was it really IT as was needed, No where was it easy ... thanks for the help many times and very good day to you too, hope you will give me a +1 – Jesper Jul 23 '15 at 21:29
0

Also have a look at the following wordpress article: Using HTML 5 data- It contains jQuery code to test whether the properties are being set. It may be beneficial to you.