4.30 Required Field Text shows when first on page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Hi, I've not worked with "required" fields yet, however, I looked at the "register" page as an example and implemented it on my plugin. When I load my page the "required" text is already popped out, I want it to only show after I hit "submit". Any idea?

cshtml example:
<div class="form-group">
                                    <div class="col-md-3">
                                        <nop-label asp-for="ItemPreFix" />
                                    </div>
                                    <div class="col-md-2">
                                        <nop-editor asp-for="ItemPreFix" />
                                        <nop-required />
                                        <span asp-validation-for="ItemPreFix"></span>
                                    </div>
                                </div>


My SetupItemValidator.cs code:

using System;
using FluentValidation;
using Nop.Plugin.TShirts.Fundraiser.Models;
using Nop.Web.Framework.Validators;

namespace Nop.Plugin.TShirts.Fundraiser.Validators
{
    /// <summary>
    /// Represents validator of configuration model
    /// </summary>
    public class SetupItem : BaseNopValidator<FundraiserSetupAddItemModel>
    {
        #region Ctor

        public SetupItem()
        {
            RuleFor(model => model.ItemPreFix)
                .NotEmpty()
                .WithMessage("Item Prefix Required");

        #endregion
    }
}


Here is a picture of what my page does when i enter:
3 years ago
bump, anyone?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.