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

2 Answers 2

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?

Sign up to request clarification or add additional context in comments.

1 Comment

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
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.