Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Ng-show = false and min and required
Message
 
 
À
Tous
Information générale
Forum:
Javascript
Catégorie:
Autre
Titre:
Ng-show = false and min and required
Divers
Thread ID:
01622902
Message ID:
01622902
Vues:
43
UPDATE. Never mind, solved the problem with conditional min using
min="{{selections.createDaily?'0': '1'}}"
UPDATE 2. Better solution is to use ng-if suggested in stackoverflow.

Hi everybody,

I have the following control on my page
 <input type="number" name="maxSale" ng-show="!selections.createDaily"
                           id="maxSale"
                           ng-model="currentmax4sale.maxSale"
                           class="form-control"
                           min="1"
                           required
                           data-sm:number
                           data-sm:number-format data-sm:focus
                           data-accuracy="0" />
                    <div class="field-validation-error">

                        <span ng-show="form.editMax4saleGeneralForm.maxSale.$error.required && form.editMax4saleGeneralForm.maxSale.$dirty">@String.Format(Messages.isRequired, Labels.limit)</span>

                        <span ng-show="(form.editMax4saleGeneralForm.maxSale.$error.min ) && form.editMax4saleGeneralForm.maxSale.$dirty">
                            @String.Format(Messages.mustBeGreaterThanOrEqualTo, Labels.limit, "1")
                        </span>
                    </div>
So, my selections.createDaily = true and the control is not shown. However, the min validation is still firing and causing the form to become $invalid. What should I do to make sure that min validation is only firing when control is visible?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Répondre
Fil
Voir

Click here to load this message in the networking platform