Is there a way to restrict users from entering characters beyond a certain limit in oracle jet? The maxlength attribute of input html element doesn't let users enter beyond the maxlength characters.
Edit based on comments:
Unfortunately OJET does not provide a way to do that. It could be done through jQuery like this:
HTML
<oj-input-text id="text-input" value="{{value}}"></oj-input-text>
JS
this.value = ko.observable("Green");
self.bindingsApplied = function(){
$($('#text-input').find('input')[0]).attr('maxlength','5');
};
bindingsApplied
is a method implicitly called by OJET after the viewModel binds with the HTML. It is similar to $(document).ready();
Original answer:
Yes there is. Not only can you limit the number of characters allowed, you can provide custom error messages as well - or let OJET display the default - when you don't meet the requirements.
HTML:
<oj-input-text value="{{value}}"
validators="[[validators]]"
placeholder="up to 10 characters">
</oj-input-text>
JS:
self.validators = ko.computed(function()
{
return [{
type: 'length',
options: {max: 10,
messageSummary : {
tooLong: 'Too Long: Too many characters'
}}}];
});
More examples here.