I'm looking to create a Bootstrap styled textbox, specifically, based on the exact example below:
<input class="span3" type="email" required>
Here's what I have so far:
@Html.TextBox("CustomerEmail", null, new { @class = "input-xlarge", type = "email", required = "required" })
However, required = "required"
clearly doesn't return just required
.
So, my question is, is there any way I can force it to return required like in the first example above when using Html.Textbox?
You seem to have applied a different class to the textbox:
input-xlarge
, whereas in your desired markup it's calledspan3
.So:
As far as the required part is concerned, the correct syntax here is
required="required"
, otherwise you simply get broken HTML.i think you should use like this
i think this will help you.
I noticed that you can also use.
The interesting thing is that you get a warning message in Visual Studio 2015 regardless. I wonder if this is a problem with a need for updating.
Warning Message:
Try
As an aside, according to the W3C docs,
required
is a Boolean attribute, and I quote:Therefore
all mean the same thing.