Validating drop down lists select list validation using javascript

, since when I remove it in the source, the select magically gets another (empty and default) option - but then the only option I wanted is no longer longer default, nor .only one. Version: 1.2.13 @himdel what about using data binding to select the single available option? p=preview A bit less code to write and seems to work as you would expect, no? I do care about the empty option so the second version doesn't work for me. it's definitely much nicer than the hack I came up with (adding a directive that triggers change after a timeout), so thanks for that :).

If you don't care about the empty option name, the HTML can be simplified a bit: N4f Mau Tyc Nzjtu HP? However, I use the form for both create and edit, so adding something akin to match the select's state, which doesn't happen here, so I think that part is a bug on angular's part.

I cannot find a way to link the first option to the model.

Do you think there is a solution to manage this case ?

If I leave it on the first option there will be no value and the rule will fail. I essentially provide an inline function that returns true or false.

validating drop down lists select list validation using javascript-65validating drop down lists select list validation using javascript-21validating drop down lists select list validation using javascript-85

But what if I only want to enable the validation of certain field based on certain conditions?

Or if I want to validate based on an event that is not the But what if I want to enable the validator from javascript?

I didn't find anything online about this so I debugged the ASP.

When creating the issue, I wasn't in the problem-solving state, I'd probably use stackoverflow for that, I was in bug-reporting state, if that makes sense :). @himdel yes, I agree that this is a corner case, but I wasn't into the hack-proposing mode :-) The thing is that IMO selection should be driven from the model. I mean, on the one hand, I don't really have a problem anymore, but on the other, there is a (albeit rather specific) case where angular model doesn't match the state of the corresponding select..

If there is no proper model selection Angular JS would try to generate an empty option anyway ( we are just killing it here with @pkozlowski-opensource I'm not sure about the model driving the selection, or rather, I think the user should be doing that, and AFAICT the user has no way of influencing the model directly. I do agree that the ) and just preselect the first real option if none is set and the list has length 1. As @himdel wrote, if the select is used (performing the "change" event), then it works as expected.

609

Leave a Reply