This topic is locked

"Text Area" with Maximun number of characters

7/30/2011 4:55:42 AM
PHPRunner General questions
I
imthebest author

In add page, I want to show "commnet" field as Text area. But in database this field has Varchar 500. Hence, more than 500 characters cannot be saved. Hence, we need to restrict user to enter more than 500 characters in the Text Area field. How can this be achieved?
I know that it is possible if we select field type as Text Field in Editor. But, I prefer to do this as Text Area.
Please advice.

C
cgphp 7/30/2011

You can use js:

var ctrlTextArea = Runner.getControl(pageid,'YourTextAreaName');
ctrlTextArea.on('keyup',function(e, argsArr){

var len = this.getValue().length;

if (len > 500)

{

alert("Maximum length allowed: 500");

this.setValue(this.getValue().substring(0, 500));

}

});