Skip to content

Commit

Permalink
Add data-val-required to input due to FluentValidator's lack of clien…
Browse files Browse the repository at this point in the history
…t-side validation support
  • Loading branch information
support committed Aug 25, 2023
1 parent 95499c5 commit 40934dc
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 88 deletions.
6 changes: 3 additions & 3 deletions src/Web/Grand.Web/Views/Account/ChangePassword.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@
<fieldset class="form-group">
<validation-provider tag="div" rules="required" name="OldPassword" v-slot="{ errors, classes }">
<label asp-for="OldPassword" class="col-form-label">@Loc["Account.ChangePassword.Fields.OldPassword"]:</label>
<input asp-for="OldPassword" v-model="changepassword.OldPassword" v-bind:class="[classes , 'form-control']" autofocus="autofocus" autocomplete="off" />
<input asp-for="OldPassword" v-model="changepassword.OldPassword" v-bind:class="[classes , 'form-control']" autofocus="autofocus" autocomplete="off" data-val-required=@Loc["Account.ChangePassword.Fields.OldPassword.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="OldPassword"></span>
</validation-provider>
</fieldset>
<fieldset class="form-group">
<validation-provider tag="div" vid="changepassword.NewPassword" rules="required" v-slot="{ errors, classes }">
<label asp-for="NewPassword" class="col-form-label">@Loc["Account.ChangePassword.Fields.NewPassword"]:</label>
<input asp-for="NewPassword" v-model="changepassword.NewPassword" v-bind:class="[classes , 'form-control']" autofocus="autofocus" autocomplete="off" />
<input asp-for="NewPassword" v-model="changepassword.NewPassword" v-bind:class="[classes , 'form-control']" autofocus="autofocus" autocomplete="off" data-val-required=@Loc["Account.ChangePassword.Fields.NewPassword.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="NewPassword"></span>
</validation-provider>
</fieldset>
<fieldset class="form-group">
<validation-provider tag="div" vid="changepassword.ConfirmNewPassword" rules="required|confirmed:@@changepassword.NewPassword" v-slot="{ errors, classes }">
<label asp-for="ConfirmNewPassword" class="col-form-label">@Loc["Account.ChangePassword.Fields.ConfirmNewPassword"]:</label>
<input asp-for="ConfirmNewPassword" v-model="changepassword.ConfirmNewPassword" v-bind:class="[classes , 'form-control']" autofocus="autofocus" autocomplete="off" />
<input asp-for="ConfirmNewPassword" v-model="changepassword.ConfirmNewPassword" v-bind:class="[classes , 'form-control']" autofocus="autofocus" autocomplete="off" data-val-equalto=@Loc["Account.ChangePassword.Fields.NewPassword.EnteredPasswordsDoNotMatch"] data-val-required=@Loc["Account.ChangePassword.Fields.ConfirmNewPassword.Required"] />
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="ConfirmNewPassword"></span>
</validation-provider>
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Grand.Web/Views/Account/DeleteAccount.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<fieldset class="form-group">
<validation-provider tag="div" rules="required" name="Password" v-slot="{ errors, classes }">
<label asp-for="Password" class="col-form-label">@Loc["Account.DeleteAccount.Fields.Password"]:</label>
<input asp-for="Password" v-model="deleteaccount.Password" v-bind:class="[classes , 'form-control']" autofocus="autofocus" autocomplete="off" />
<input asp-for="Password" v-model="deleteaccount.Password" v-bind:class="[classes , 'form-control']" autofocus="autofocus" autocomplete="off" data-val-required=@Loc["Account.DeleteAccount.Fields.Password.Required"] />
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Password"></span>
</validation-provider>
Expand Down
24 changes: 12 additions & 12 deletions src/Web/Grand.Web/Views/Account/Info.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<validation-provider tag="div" rules="required" name="FirstName" v-slot="{ errors, classes }">
<label asp-for="FirstName" class="col-form-label">@Loc["Account.Fields.FirstName"]:</label>
<span class="required">*</span>
<input asp-for="FirstName" v-model="customer.FirstName" v-bind:class="[classes , 'form-control']" autofocus="autofocus" />
<input asp-for="FirstName" v-model="customer.FirstName" v-bind:class="[classes , 'form-control']" autofocus="autofocus" data-val-required=@Loc["Account.Fields.FirstName.Required"] />
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="FirstName"></span>
</validation-provider>
Expand All @@ -131,7 +131,7 @@
<validation-provider tag="div" rules="required" name="LastName" v-slot="{ errors, classes }">
<label asp-for="LastName" class="col-form-label">@Loc["Account.Fields.LastName"]:</label>
<span class="required">*</span>
<input asp-for="LastName" v-model="customer.LastName" v-bind:class="[classes , 'form-control']" autofocus="autofocus" />
<input asp-for="LastName" v-model="customer.LastName" v-bind:class="[classes , 'form-control']" autofocus="autofocus" data-val-required=@Loc["Account.Fields.LastName.Required"] />
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="LastName"></span>
</validation-provider>
Expand Down Expand Up @@ -178,7 +178,7 @@
<validation-provider tag="div" rules="required|email" name="Email" v-slot="{ errors, classes }">
<label asp-for="Email" class="col-form-label">@Loc["Account.Fields.Email"]:</label>
<span class="required">*</span>
<input asp-for="Email" v-model="customer.Email" v-bind:class="[classes , 'form-control']" autofocus="autofocus" asp-readonly=@(!Model.AllowUsersToChangeEmail) />
<input asp-for="Email" v-model="customer.Email" v-bind:class="[classes , 'form-control']" autofocus="autofocus" asp-readonly=@(!Model.AllowUsersToChangeEmail) data-val-email=@Loc["Common.WrongEmail"] data-val-required=@Loc["Account.Fields.Email.Required"] />
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Email"></span>
</validation-provider>
Expand All @@ -194,7 +194,7 @@
<validation-provider tag="div" rules="required" name="Username" v-slot="{ errors, classes }">
<label asp-for="Username" class="col-form-label">@Loc["Account.Fields.Username"]:</label>
<span class="required">*</span>
<input asp-for="Username" v-model="customer.Username" v-bind:class="[classes , 'form-control']" autofocus="autofocus" />
<input asp-for="Username" v-model="customer.Username" v-bind:class="[classes , 'form-control']" autofocus="autofocus" data-val-required=@Loc["Account.Fields.Username.Required"] />
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Username"></span>
</validation-provider>
Expand Down Expand Up @@ -232,7 +232,7 @@
<validation-provider tag="div" rules="required" name="Company" v-slot="{ errors, classes }">
<label asp-for="Company" class="col-form-label">@Loc["Account.Fields.Company"]:</label>
<span class="required">*</span>
<input asp-for="Company" v-model="customer.Company" v-bind:class="[classes , 'form-control']" autofocus="autofocus" />
<input asp-for="Company" v-model="customer.Company" v-bind:class="[classes , 'form-control']" autofocus="autofocus" data-val-required=@Loc["Account.Fields.Company.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Company"></span>
</validation-provider>
Expand Down Expand Up @@ -280,7 +280,7 @@
<validation-provider tag="div" rules="required" name="StreetAddress" v-slot="{ errors, classes }">
<label asp-for="StreetAddress" class="col-form-label">@Loc["Account.Fields.StreetAddress"]:</label>
<span class="required">*</span>
<input asp-for="StreetAddress" v-model="customer.StreetAddress" v-bind:class="[classes , 'form-control']" autofocus="autofocus" />
<input asp-for="StreetAddress" v-model="customer.StreetAddress" v-bind:class="[classes , 'form-control']" autofocus="autofocus" data-val-required=@Loc["Account.Fields.StreetAddress.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="StreetAddress"></span>
</validation-provider>
Expand All @@ -302,7 +302,7 @@
<validation-provider tag="div" rules="required" name="StreetAddress2" v-slot="{ errors, classes }">
<label asp-for="StreetAddress2" class="col-form-label">@Loc["Account.Fields.StreetAddress2"]:</label>
<span class="required">*</span>
<input asp-for="StreetAddress2" v-model="customer.StreetAddress2" v-bind:class="[classes , 'form-control']" autofocus="autofocus" />
<input asp-for="StreetAddress2" v-model="customer.StreetAddress2" v-bind:class="[classes , 'form-control']" autofocus="autofocus" data-val-required=@Loc["Account.Fields.StreetAddress2.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="StreetAddress2"></span>
</validation-provider>
Expand All @@ -324,7 +324,7 @@
<validation-provider tag="div" rules="required" name="ZipPostalCode" v-slot="{ errors, classes }">
<label asp-for="ZipPostalCode" class="col-form-label">@Loc["Account.Fields.ZipPostalCode"]:</label>
<span class="required">*</span>
<input asp-for="ZipPostalCode" v-model="customer.ZipPostalCode" v-bind:class="[classes , 'form-control']" autofocus="autofocus" />
<input asp-for="ZipPostalCode" v-model="customer.ZipPostalCode" v-bind:class="[classes , 'form-control']" autofocus="autofocus" data-val-required=@Loc["Account.Fields.ZipPostalCode.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="ZipPostalCode"></span>
</validation-provider>
Expand All @@ -346,7 +346,7 @@
<validation-provider tag="div" rules="required" name="City" v-slot="{ errors, classes }">
<label asp-for="City" class="col-form-label">@Loc["Account.Fields.City"]:</label>
<span class="required">*</span>
<input asp-for="City" v-model="customer.City" v-bind:class="[classes , 'form-control']" autofocus="autofocus" />
<input asp-for="City" v-model="customer.City" v-bind:class="[classes , 'form-control']" autofocus="autofocus" data-val-required=@Loc["Account.Fields.City.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="City"></span>
</validation-provider>
Expand All @@ -368,7 +368,7 @@
<validation-provider tag="div" rules="required" name="CountryId" v-slot="{ errors, classes }">
<label asp-for="CountryId" class="col-form-label">@Loc["Account.Fields.Country"]:</label>
<span class="required">*</span>
<select asp-for="CountryId" asp-items="Model.AvailableCountries"
<select asp-for="CountryId" asp-items="Model.AvailableCountries" data-val-required=@Loc["Account.Fields.Country.Required"]
onchange="@Html.IdFor(model => model.CountryId)_select_element(this)" v-bind:class="[classes , 'form-control custom-select']" v-model="customer.CountryId"></select>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="CountryId"></span>
Expand Down Expand Up @@ -432,7 +432,7 @@
<validation-provider tag="div" rules="required" name="Phone" v-slot="{ errors, classes }">
<label asp-for="Phone" class="col-form-label">@Loc["Account.Fields.Phone"]:</label>
<span class="required">*</span>
<input asp-for="Phone" v-bind:class="[classes , 'form-control']" v-model="customer.Phone" />
<input asp-for="Phone" v-bind:class="[classes , 'form-control']" v-model="customer.Phone" data-val-required=@Loc["Account.Fields.Phone.Required"]/>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Phone"></span>
</validation-provider>
Expand All @@ -455,7 +455,7 @@
<validation-provider tag="div" rules="required" name="Fax" v-slot="{ errors, classes }">
<label asp-for="Fax" class="col-form-label">@Loc["Account.Fields.Fax"]:</label>
<span class="required">*</span>
<input asp-for="Fax" v-bind:class="[classes , 'form-control']" v-model="customer.Fax" />
<input asp-for="Fax" v-bind:class="[classes , 'form-control']" v-model="customer.Fax" data-val-required=@Loc["Account.Fields.Fax.Required"] />
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Fax"></span>
</validation-provider>
Expand Down
6 changes: 3 additions & 3 deletions src/Web/Grand.Web/Views/Account/Login.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</div>
<div class="col-lg-9 col-12">
<validation-provider tag="div" rules="required" name="UserName" v-slot="{ errors, classes }">
<input asp-for="Username" v-model="login.Username" v-bind:class="[classes , 'form-control']" autofocus="autofocus" />
<input asp-for="Username" v-model="login.Username" v-bind:class="[classes , 'form-control']" autofocus="autofocus" data-val-required=@Loc["Account.Login.Fields.UserName.Required"] />
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Username"></span>
</validation-provider>
Expand All @@ -49,7 +49,7 @@
</div>
<div class="col-lg-9 col-12">
<validation-provider tag="div" rules="required|email" name="Email" v-slot="{ errors, classes }">
<input asp-for="Email" v-model="login.Email" v-bind:class="[classes , 'form-control']" autofocus="autofocus"/>
<input asp-for="Email" v-model="login.Email" v-bind:class="[classes , 'form-control']" autofocus="autofocus" data-val-email=@Loc["Common.WrongEmail"] data-val-required=@Loc["Account.Login.Fields.Email.Required"] />
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Email"></span>
</validation-provider>
Expand All @@ -63,7 +63,7 @@
</div>
<div class="col-lg-9 col-12">
<validation-provider tag="div" rules="required" name="Password" v-slot="{ errors, classes }">
<input asp-for="Password" v-model="login.Password" v-bind:class="[classes , 'form-control']" autocomplete="off" />
<input asp-for="Password" v-model="login.Password" v-bind:class="[classes , 'form-control']" autocomplete="off" data-val-required=@Loc["Account.Login.Fields.Password.Required"] />
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="Password"></span>
</validation-provider>
Expand Down
Loading

0 comments on commit 40934dc

Please sign in to comment.