Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ng-show = false and min and required
Message
 
 
To
All
General information
Forum:
Javascript
Category:
Other
Title:
Ng-show = false and min and required
Miscellaneous
Thread ID:
01622902
Message ID:
01622902
Views:
44
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
Reply
Map
View

Click here to load this message in the networking platform