I have the following textbox in my View
:
The code for the placeholder:
@Html.TextBoxFor(m => m.Listing.Location.AddressLine1, new {@placeholder="Address Line 1 - Required"})
Question: How do I make the text "Required" in RED.
I have the following textbox in my View
:
The code for the placeholder:
@Html.TextBoxFor(m => m.Listing.Location.AddressLine1, new {@placeholder="Address Line 1 - Required"})
Question: How do I make the text "Required" in RED.
You can't do this with a text field. You have no control over the formatting of only some portions of the HTML5 placeholder
attribute. Not to mention that if you want to achieve multicolor text you can no longer use a text field or textarea. You will have to use an element with contenteditable="true"
attribute and write your custom plugin.
Here's for example how the markup might look like:
<div contenteditable="true">
Address Line 1 - <span style="color: red">Required</span>;
</div>
But since this is a div
element you will now have to back it up with a corresponding hidden field so that the value is sent to the server. Also when the value of this field changes you need to resynchronize the hidden field value as well. It will be a lot of work.
in model
[Required]
public string AddressLine1{ get; set; }
@Html.TextBoxFor(model => model.Listing.Location.AddressLine1, new { @class = "form-control" , placeholder = "Address Line 1 - Required" })
try this for an empty @Html.TextBox
@Html.TextBox("CustomarName" ,null, new { @class = "form-control" , @placeholder = "Search With Customar Name" })