简体   繁体   中英

Limiting how many checkboxes can be checked in Powermail Typo3

有没有一种方法可以限制可以在Powermail表单(Typo3 v7)中选中的复选框?

We have to write our own validator. Typo3 add some variables within name attribute and this variable has to be read out. It looks like this:

name="tx_powermail_pi1[field][variable][]

Below an example with jquery.

$("input[name*='variable']").change(function(){
    var max= 3;
    if( $("input[name*='variable']:checked").length == max ){
        $("input[name*='variable']").attr('disabled', 'disabled');
        $("input[name*='variable']:checked").removeAttr('disabled');
    }else{
        $("input[name*='variable']").removeAttr('disabled');
    }
});

More info https://docs.typo3.org/typo3cms/extensions/powermail/ForDevelopers/WriteOwnValidators/Index.html

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM