1

私はrcpでswtjfaceを使用してEclipseJavaに取り組んでいます。テキストボックスの文字を制限するにはどうすればよいですか。テキストボックスに4文字だけを入れたい場合は、どうすればよいですか?英数字の組み合わせが必要な場合はどうなりますか。再び特定の制限で?

4

3 に答える 3

0

文字を制限するには、この関数の例を見てください

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;}
  } 
于 2010-04-20T05:09:43.640 に答える
0

これはあなたのために働きますか?

SWT/LimitthenumberofcharactersthattheStyledTextaccepts.htm">http://www.java2s.com/Tutorial/Java/0280_SWT/LimitthenumberofcharactersthattheStyledTextaccepts.htm

于 2011-02-28T17:09:37.077 に答える