I'm writing this question here after trying to find an answer for two days.
basically here's what's going on.
I have a property in the viewmodel as follows
[Required(ErrorMessage = "Required Field")]
[Url(ErrorMessage="Please enter a valid url")]
[DisplayName("Website")]
public string web { get; set; }
in the view, I have this
@Html.EditorFor(model => model.web, new { AutoCompleteType = "Disabled", autocomplete = "off" })
now the problem lies in how the input text for this field is validated in the client side. the field must have the protocol prefix at all times, otherwise it becomes invalid.
what is the best way I can fix this issue?
Many Thanks
[Url(UrlOptions.OptionalProtocol)]
. but for theUrlOptions
to be available, I have to addusing DataAnnotationsExtensions
, then theUrl
becomes ambiguous. to correct that, I used[DataAnnotationsExtensions.Url(UrlOptions.OptionalProtocol)]
but it doesn't validate in the front end. – Pitchblende