How do you limit the amount of digits in a text field?

If a user was to input 9 digits into a text field. How do you make it so that an error message would appear if the user inputs more than 9 digits

That code will set the TextFields length to 9 standard charecters (might not be 9 though) To limit the number of charecters and throw an error message I would use a listener on the textField. Perhaps a keyListener that keeps track of the number of charecters. ( swing has document listeners which are really nice )

Similar Messages

  • Limit the amount of characters of a text field based on first digit

    Hello and thanks in advance for your help!
    I would like to limit the amount of characters of the text field based on the first digit of the number (the text field is only limited to a number format...no decimals, no commas).
    For example, if the number begins with a 3, I would like to limit the text field to allow only ten characters. I have three scenarios but if I could get started with some code and what is the best place to add it (keystroke or validation?) I can take it from there. Thanks again for your help!!

    I've written this code for you that does that. Use it as the field's custom Keystroke code:
    // Validate that only digits are entered
    if (event.change) {
        event.rc = /^\d+$/.test(event.change);
    // Validate string length if it starts with 3
    if (/^3/.test(AFMergeChange(event))) {
        event.rc = AFMergeChange(event).length <= 10;
        if (!event.rc) app.alert("If the number starts with \"3\" it may not be longer than 10 digits.",1); // optional error message
    You can duplicate the second part of it for additional conditions, but keep in mind that this code won't even let you remove the first character in the field if the result is an invalid one.
    For example, if you enter "234567890123456" then you can't remove the "2" at the start because that would result in an invalid number. You can remove any of the other digits, though, and when it's 10 digits or less then you could remove the starting "2" as well.

  • HT204264 How do I limit the amount of space used by photos on my phone - now that I turned iCloud on it is taking over my phone

    How do I limit the amount of space used by photos on my phone - now that I turned iCloud on it is taking over my phone

    Hello Maahk,
    Welcome to the Apple Support Communities!
    I understand that you would like to optimize your Photos storage. If you are using iCloud Photo Library on your iPhone, please read over the information in the attached article. 
    iCloud Photo Library FAQ - Apple Support
    Can I use iCloud Photo Library to save space on my device?
    iCloud Photo Library automatically keeps all your photos and videos in the original, high-resolution version. Follow these steps to choose how you store your photos and videos on your device:
    In iOS, tap Settings > iCloud > Photos or Settings > Photos & Camera, then select a storage setting.
    In OS X, click Photos > Preferences > iCloud, then select a storage setting. 
    If you turn on Optimize [device] Storage, iCloud Photo Library will automatically manage the size of your library on your device, so you can make the most of your device's storage and access more photos than ever. All of your original, full-resolution photos and videos are stored in iCloud while device-size versions are kept on your device. You can download the original photos and videos over Wi-Fi or cellular when you need them. 
    If you turn on Download Originals, iCloud Photo Library will keep your original, full-resolution photos and videos in iCloud and on your device. Download Originals is the default setting for iOS devices with the free 5 GB storage plan and for all Mac devices.
    Have a great day,
    Joe

  • How do you limit the content of Launch pad screens

    How do you limit the content of Launch pad screens - mine is cluttered with many applications - which are all valid - but many are so raely used they are causing me to have two screes - I want one screen possibly half filled. Can anybody help...

    I believe you need to manually delete them one at a time..
    Are the emails from an IMAP account(s)

  • How do you set the amount of time the screen stays lite after your last use?

    How do you set the amount of time the screen stays lite after your last use?

    Settings>General>Auto-Lock.

  • TS3899 In ios7 how do you limit the number of emails downloaded from your ISP server?  Previous version allowed you to limit it to 50, 100, etc.

    In ios7 how do you limit the number of emails downloaded from the ISP server?  Previous version allowed you limit the download to the last 50, 100, etc.

    Hi,
    Unfortunately, this is a feature that Apple have taken away.
    The best way to let them know you want it back is via http://www.apple.com/feedback/
    Regards

  • How do you limit the number of emails that download in ios7?

    How do you limit the number of emails that download in iOS7? In previous versions, I was able to limit (i.e. 50/100/ etc), the number that would download to my phone at any given time - other than new emails. Past/old emails would only be reloaded if I deleted newer ones or I requested more be loaded.

    Now solved:
    https://discussions.apple.com/thread/5325394?tstart=0
    Guy in my thread fixed it for me. Very simple to do.

  • How do you limit the number of rows return from query?

    How do you limit the number of rows return from query? Do all databases support this kind of feature?

    i think the standard is limit
    to get the top 30
    select * from mytable LIMIT 30;returns the first 30 rows
    also if you want a range
    select * from mytable LIMIT 10,30;returns 30 rows starting from 10
    this last one is useful for displaying ranges... something similar happens in these forums when viewing topics and messages

  • Can you limit the amount of data accessed per user on an AirPort Extreme?

    Can you limit the amount of data accessed per user on an AirPort Extreme?

    Your question was whether the AirPort Extreme is able to establish data limits per user.
    If you add another router that has this type of capability or install software on another router, then you will be able to establish data limits for each user. The AirPort Extreme will have no control over this.

  • How do you change the font color in CALL-OUT text boxes in PRO XI?

    How do you change the font color in CALL-OUT text boxes in PRO XI?

    It's not so simple to find it if you don't know what you're looking for... But it can be found via View - Show/Hide - Toolbar Items - Properties Bar.

  • How do you grey out a radio button if a text field is blank in Adobe Acrobat XI Pro?

    How do you grey out a radio button if a text field is blank in Adobe Acrobat XI Pro?
    So this what I'm trying to do:
    (     )   |TEXT FIELD|
    (     )   |TEXT FIELD|
    (     )   |                  |
    (     )   |TEXT FIELD|
    I have a radio button: (     )
    and a text field: |TEXT FIELD|
    The third text field is blank, and I would like for the radio button next to it greyed out (user can't click on it) since the text field is blank. Is this possible to achieve? I'm assuming I'll have to use javascript, but what would the code be and would it be entered in the javascript editor for the text field or the radio button?
    Thanks in advance guys

    Hey, thanks, but it didn't work
    I have the text fields as read only. Could that be why it's not working? Should I make the fields not read only?
    Thanks,

  • How can I limit the amount of space on a Time Capsule used by Time Machine?

    I know that you cannot partition a Time Capsule drive.  However, I was wondering about other options for limiting the amount of space used by Time Machine so that I can use the rest of the space for other purposes.
    I heard something about creating a disk image on the Time Capsule to limit the amount of space used by Time Machine.  If I create a disk image, would TM just use all the space that's not part of the disk image?  How do I access the disk image part?  Can I manually drag and drop files to it from my Mac like any other external drive?  Could I set up the disk image part to work with a Windows computer?
    I've also heard things about modifying sparsebundles which I don't know anything about.  How does this work?  What happens to the space that is not part of the TM sparsebundle?  How do I access it?  Can I manually drag and drop files to it from my Mac like any other external drive?  Could I set up the extra space to work with a Windows computer?

    Some other things to make note of:
    Some disk image formats have a maximum size and only use that size after they have had to expand to actually hold that much data. Make sure you are not using this type of image so you can guarantee the space is reserved. Sparse bundles are like this. I haven't read up on the sparse bundle trick, but I assume it's something to do with setting a maximum size for it.
    When you open up the Time Capsule disk, you will first be looking at the normal storage space. When you create an image, there will be a file you click on that mounts another drive that uses space on the Time Capsule. This shows up as just one file unless you open it to see it's contents.

  • How do I limit the amount of emails in my inbox

    We have a mail server at our business, I receive my mail on my PC, laptop,iPad and iPhone. The iPhone and iPad fetch my mail and as soon as I read my mail on my iPhone or iPad it loads old mail from the server. This did not happen before our last update from Apple.
    This means I pay at least 3 time to download my mail.
    Is it possible to limit the amount of mail and only receive the heading and download the rest should you need to?

    This is no longer an option.
    Feel free to let Apple know about it by sending them feedback:  www.apple.com/feedback

  • How do you reduce the amount of mb used by other i dont know what this is?

    how do i reduce the amount of mb used by other on my itunes do i can record more videos?

    http://osxdaily.com/2013/07/24/remove-other-data-storage-iphone-ipad/

  • How do you limit the number of rings before your answerphone kicks in?

    People calling me have sometimes complained that if I am not available to take the call, they have to wait for many rings - and hence a long time - before the messaging system kicks in. And sometimes, callers give up, assuming I don't have voicemail. I know you can limit the number of rings on other phones, but I haven't founf out how to do it with my iPhone. I'm sure it's easy though!!

    Your carrier sets this by time, not the number of "rings" since different ring tones take different times/ring.  The typical setting is 30 seconds, sometimes up to 40 seconds.  Contact your carrier to shorten it.

Maybe you are looking for

  • How to upload data from  flat to ztables with in the same client by idocs

    Hi Experts,                I have a requirement in IDOCS, I need to create a custom IDOC .I  am working on IDES 4.6c. The reqirement is , there  are ztables with header and item data. say for example Authors and Books. I need to upload data from flat

  • How to provide the user with a list of files to pick from...for downloading

    hai.. I have uploaded the file succesfully.. now we need to download the file...... which has been uploaded..... for that we have implemnted the Query as.. select max(id) from APEX_APPLICATION_FILES ,here the latest uploaded record will be retrieved

  • How can I import cinema dng files in Premiere Pro CC?

    Hi, I wanna use Blackmagic Cinema DNG 4k RAW files for my productions in Premiere. As specified by Adobe that schould be no problem. When I import the dng-folder or a list of *.dng files they are displayed in assets view as single photos. How can I c

  • Hi I want Help

    I would like to have some finance project models and case studeis ..please provide me that as its very urget for me and I will definitely assign points...What kind of extractors available (FI) and what are the roles of Finance programmers and any pro

  • SQL*Plus + rlwrap + Terminator = tolerable environment

    I have no doubt that those who are "full-time" users of sqlplus (that is a native Oracle's textmode client app to the database server), will agree that it provides a spartan and unimaginative command-line interface. Unlike most modern command-line ut