29 April, 2014

Maxvalue validation for textarea using AlloyUI - IE

You might be aware that maxlength attribute of textarea doesn't work for IE8 & IE9. If you still want to restrict the length then you can use below code using alloyUI :
A.one(document).delegate(['keypress','change'],function(e){
var maxLength = this.attr('maxlength');
  if(this.val().length > maxLength) {
   this.val(this.val().substring(0, maxLength));
   e.preventDefault();
}
}, '#<portlet:namespace/>description');


Using jQuery :

jQuery("#<portlet:namespace/>description").on('keypress',function(e){
var maxLength = this.attr('maxlength');
  if(this.val().length > maxLength) {
   this.val(this.val().substring(0, maxLength));
   e.preventDefault();
}
});

Rate Me:

Liferay 7.3 compatibility matrix

Compatibility Matrix Liferay's general policy is to test Liferay Portal CE against newer major releases of operating systems, open s...