how to set an element to be required webmethods caf using javascript

I want to set required=true of an input in caf webmethods using javascript.

this my code that I try to set required:

if (CAF.model('#{activePageBean.clientIds['dropDowntypeFlux']}').getValue() == 'expo'){
     CAF.model('#{activePageBean.clientIds['htmlInputMatricule']}').setAttribute("required", "true");
}

but it does not work.

Are you sure it doesn’t work? Maybe it just doesn’t get executed? You have to trigger that code somehow (using some events?).

I’m sure that not work

Did u solve it? Nothing works!

I tried whit

CAF.model('#{activePageBean.clientIds["htmlInputText4Comentario"]}').required = true;

didnt work.