Reputation: 93
I am working on eclipse java using swt jface with rcp. How can i limit the characters in my text box. Like if i want only 4 characters in my text box then what should i do? and what if i want alphanumeric combination . again in certain limit?
Upvotes: 1
Views: 1983
Reputation: 1555
does this work for you?
SWT/LimitthenumberofcharactersthattheStyledTextaccepts.htm">http://www.java2s.com/Tutorial/Java/0280_SWT/LimitthenumberofcharactersthattheStyledTextaccepts.htm
Upvotes: 0
Reputation: 3271
Please look this function example for limit the character
function check_length_year(my_form) {
maxLen = 4; // max number of characters allowed
if (my_form.retire_year.value.length > maxLen) {
// Alert message if maximum limit is reached.
// If required Alert can be removed.
// var msg = "You have reached your maximum limit of characters allowed";
// alert(msg);
// Reached the Maximum length so trim the textarea
my_form.retire_year.value = my_form.retire_year.value.substring(0, maxLen);
return false;
} else { // Maximum length not reached so update the value of my_text counter
my_form.year_num.value = maxLen - my_form.retire_year.value.length;}
}
Upvotes: 0