<div class="form-group">
<label asp-for="Url" class="col-xs-12 control-label"></label>
<div class="col-xs-12">
<input asp-for="Url" class="form-control" />
<span asp-validation-for="Url" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label asp-for="Email" class="col-xs-12 control-label"></label>
<div class="col-xs-12">
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
</div>
/*DataType attribute is enough to select the right
Html5 input and to apply the right validation rules
*/
public class VariousExample
{
[DataType(DataType.Url)]
public string Url { get; set; }
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
}
public IActionResult Various()
{
return View();
}
[HttpPost]
public IActionResult Various(VariousExample vm)
{
return View(vm);
}