Hi Team
I have 5 textbox and want to find a way to make them when leaving will have label error message. So far i have done the following and seem not winning, kind need of an assistance please mates.
- class="row">
- ="Address">Address
class="col-md-6 ">class="input-group pull-right">- @Html.TextBoxFor(m => m.HomeMainModel.Address, new { @class = "form-control", type = "text", id = " street address", autofocus = "autofocus", placeholder = "Street Address", required = "required" })
class="input-group-append">class="input-group-text"> - class="col-md-6 col-sm-10 col-xs-10">
- class="text-danger" style="display:none">
-
- class="row">class="col-md-6 ">class="input-group pull-right">
- @Html.TextBoxFor(m => m.HomeMainModel.Address, new { @class = "form-control", type = "text", id = "address", autofocus = "autofocus", placeholder = "Street Address Line 2", required = "required" })
class="input-group-append">class="input-group-text"> - class="form-group">class="input-group mb-2">class="input-group-prepend">class="input-group col-md-7 col-md-offset-7 col-sm-7 col-xs-7">class="input-group pull-right">
- @Html.TextBoxFor(m => m.HomeMainModel.City, new { @class = "form-control", type = "text", id = "city", autofocus = "autofocus", placeholder = "City", required = "required" })
- @Html.TextBoxFor(m => m.HomeMainModel.State, new { @class = "form-control", type = "text", id = "state", autofocus = "autofocus", placeholder = "State/ Province", required = "required" })
class="input-group-append">class="input-group-text">class="col-md-6 col-sm-10 col-xs-10">- class="text-danger" style="display:none">
class="input-group mb-2">class="input-group-append">class="input-group col-md-7 col-md-offset-3 col-sm-2 col-xs-2">class="input-group pull-right">- @Html.TextBoxFor(m => m.HomeMainModel.Code, new
- {
- @class = "form-control",
- type = "text",
- id = "postal code",
- autofocus = "autofocus",
- placeholder = "Postal/Zip Code"
- })
- @Html.DropDownListFor(m => m.HomeMainModel.SelectedCountryId, this.ViewBag.CountryList as SelectList, new { @class = "form-control" })
class="input-group-append">class="input-group-text"> - class="col-md-6 col-sm-10 col-xs-10">
- class="text-danger" style="display:none">
- // function when leaving texbox for city, street address, street_address_line2, state_province.
- $(function() {
- $('#City').blur(function() {
- var city = document.getElementById("City").value;
- var expr = /^([\w-\.]+)@@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
- if (!expr.test(city)) {
- document.getElementById("labelMessaget").style.display = "inline";
- } else {
- document.getElementById("labelMessaget").style.display = "none";
- }
- });
- });

Vinay SinghRank #604 · 4K reputationPosted Mar 25, 2020, 9:20 PM EDT
Guest UserRank #877 · 2.5K reputationPosted Mar 25, 2020, 9:41 PM EDT
Vinay SinghRank #604 · 4K reputationPosted Mar 25, 2020, 9:45 PM EDT