I have this JQuery piece to prevent selection of dropdown options that are already selected in another field.
var $coll = $( 'select[name$="service"]' ).on( 'change', function () {
$coll.each(function () {
var val = this.value;
if ( val === 'original' ) return;
$coll.not( this ).children( '[value="' + val + '"]' ).prop( 'disabled', true );
});
});
The problem is that this only works when you start selection from scratch (empty form). When I have a form that has fields with pre-selected options, the function only kicks in after the second attempt.
Do you know how I can change this to check for pre-filled fields as well?
我要做的就是在准备好文档后对.trigger("change")
进行.trigger("change")
,以便使验证在第一次选择之前开始。
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.