My HTML code
<select value.bind="selectedValue & validate"> <option value="0">Add Location Type</option> <option repeat.for="item of listOfValuesFromDB" model.bind="item.TeamLocationTypeId">${item.Name}</option> </select>
My VM has
ValidationRules.ensure('selectedValue').inclusion({ within: [1, 2, 3], fullMessages: true, message: 'Please select an Item' });
Suppose, if i select within [1,2,3] from the dropdown list, it just works fine by no throwing any validation. But since the list has growing dynamic data, it will throw error if i select anything else apart from 1,2,3.
I am new to Aurelia framework. Please help.
If you're just looking to ensure that the user selects an item other than "0", you could use the following validation code:
ValidationRules.ensure('selectedValue').required();
And remove value="0"
from your default option
tag.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.