I'm quite new to UI development.
I have a textfield. (input) where the user enters a string for SMS. I want to discard all the characters which are more than 120. I have written code for this one.
Problem: if the user enters more than 120 characters, how do I remove the last extra character? (I shouldn't let him to enter more than 120)
How do I do it?
this is my code for input change:
onSMSMessageInputChange : function(){
var smsText=$(this.ui.smsInput).val().substring(0,120); //get entered text
this.model.setProp("smsMessages",smsText); //set it to a model
},
You can use a maxlength attribute (see docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea) to limit the amount of characters that a person can enter.