Welcome to the IBM Collaboration Solutions Community IQJam.
UsernamePassword
Reset Password | Register
   
Home | Leader Board | Tags | Help
textfield formatting 
I would like to do the following:
 
Have a textfield for a field that only allows uppercase letters to be typed.  I know that I can convert to uppercase, but I want to restrict the typing to uppercase in the user's interface.

Additionally, I would like to have a textfield that works in a specific format:

######AAAAAAAA where:
 
# is number only and A is uppercase letter only.

Thanks 
Domino Development / XPages
Tagged
John Coombs - about 1 year ago |  |  | Viewed 166 times

There are 3 answers

1votes
The way to do this would be to write a client side javascript function in one the onKeyDown/onKeyUp/onKeyPress events of the field ... in that function you can do something like this:
 
if(window.event) { // IE
    keynum = e.keyCode
} else if(e.which) {  // Netscape/Firefox/Opera
    keynum = e.which
}
keychar = String.fromCharCode(keynum)
 
then keychar will be the character they entered.  I believe in onKeyDown, you can return false, and it will not record the character, but you'll have to experiment to make sure.


Jeremy Hodge - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
If you use thisEvent in the client side script, you could do something like this:
if( !/[A-Z]/.test( thisEvent.keyChar ) ){
   dojo.stopEvent( thisEvent );
}
 
The above code stops the event when the key entered isn't an uppercase letter. 


Tommy Valand - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes

There's a client side jQuery plugin which lets you set up, and enforce, various input masking options: Masked Input Plugin Perhaps there's a Dojo equivalent?



Ben Poole - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community