Restricting the length of an input field

Hi, I'm trying to display some form of component on screen that only allows a specific number of characters to be entered into it. I tried initialising a JTextField with a length but this refers to the display length as opposed to the maximum number of characters that can be entered. For example, if I want to ask a user to enter a year, I only want them to enter up to 4 characters.
Any ideas ?

Another way is to create your own Document, for
example, by extending PlainDocument and overriding the
insertString() method. The 1.3 docs for JTextField
give an example for a JTextField that makes all input
upper case. This approach is more complex but may
provide more pleasing results.Use this method, otherwise you can paste more than 4 characters into the JTextField...

Similar Messages

  • How to restrict the length of input field

    Hi,
    How to restrict the length of input field. That is we should not be able to enter more thatn 10 charecters.
    Regards,
    H.V.Swathi

    Hi swathi,
    For this you have to create a simple data type. No need of writing a code.
    Go to Dictionaries -> Local Dictionary -> Data Type - > Simple Type - > Right click and "Create Simple Type".
    Here you should create a Simple type with String as built-in Type. Here you will also see the Length Constraints option.
    Set the value of maximum length and minimum length. In your case set the value of maximum length to 10. At runtime this will not allow the user to enter more than 10 characters.
    Now create an attribute and bind it to this newly created simple type. Bind the value of the input field with this particular attribute.
    Regards
    Manohar

  • How to restrict the length of the input?

    Hi all, could any one tell me how to restrict the length of the input string? My SOA Suite is 10.1.3.1
    I tried the following; getting an error.
    <element name="RestrictLengthProcessRequest">
    <simpleType name="SSN">
    <restriction base="string">
    <length value="10"/>
    </restriction>
    </simpleType>
    where RestrictLengthProcessRequest is the message name of the corresponding .wsdl and SSN is the input whose length is to be restricted.
    The error is : 'Attribute name not defined on element simpleType'
    Thanks in advance.
    Edited by: user11275112 on Aug 27, 2009 11:44 PM

    Hi swathi,
    For this you have to create a simple data type. No need of writing a code.
    Go to Dictionaries -> Local Dictionary -> Data Type - > Simple Type - > Right click and "Create Simple Type".
    Here you should create a Simple type with String as built-in Type. Here you will also see the Length Constraints option.
    Set the value of maximum length and minimum length. In your case set the value of maximum length to 10. At runtime this will not allow the user to enter more than 10 characters.
    Now create an attribute and bind it to this newly created simple type. Bind the value of the input field with this particular attribute.
    Regards
    Manohar

  • How to get the vlaue from an input field without hitting the enter button ?

    Hello All,
      Is there some way to read the values of an input field that was filled in by an user eg ..
    String userEntry = wdContect.<UIElement>.value;
      So far, I am only able to achieve this using the onEnter property whoch really is not very user friendly since I can only read in the values only if the user hits enter.
      Any help will be appreciated.  Thank you.
    from
    Kwok Wei

    1. Create a value attribute (MyText) in the controller context
    2. Create a value attribute (MyText) in the view context
    3. Map view context attribute to controller context attribute
    4. Create InputField in the view and map the "value" attribute to the MyText view context attribute
    5. Create Action on view (Send)
    6. Create Send button and specify Send action as onAction attribute
    7. Create executeSend() method on controller
    8. onActionSend() implementation:
      public void onActionSend(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionSend(ServerEvent)
       wdThis.wdGet<controllername>Controller().executeSend();
        //@@end
    9. executeSend() implementation:
      public void executeSend( )
        //@@begin executeSend()
                   // Get MyText
                   String MyText = wdContext.currentContextElement().getMyText();

  • Can we config the SU as an input field in source of putaway sys-guided ?

    Experts,
    If i want to do putaway system guided/by TO for SU managed materials , there is nothing that i need to scan in the source field and i can only see the SU,Storage bin input field in the destination screen(Can only config these two fields as input fileds for scanning).So the user has to manually hit F1 save and hit Next to go the destination screen.How should i have the SU field to be scanned in source? (Can we make the SU field as an input field for scanning in source screen?)
    Thanks in advance

    We have configured both SU and src bin as input fields on RF.  Are you using customised RF program or SAP standard?  WE have this driven through a mix of stnd and customised referring back to Verifcation Data Profiles and movt assignments in Mobile Data entry configuration of LE->WM

  • Restricting the length of strings...

    I'm wondering if it is possible to restrict the length of a string produced by the String.valueOf(double) method. Here is an example:
    public class DoubleTest
         public static void main(String[] args)
              double d = 20.0;
              double d2 = 2.4;
              double value = (d/d2);
              String doubleString = String.valueOf(value);
              System.out.println(value);
    }This code will output "8.333333333333334" when run. Is there a way to restrict it to fewer decimal places, for example: "8.34"?
    Thanks a lot,
    Eric

    If you use DecimalFormat, you can specify the number of digits after the decimal point by using a 'pattern' in the constructor to DecimalFormat.
    Use '#' in the pattern for digits which will not show any leading zeros.
    Use '0' in the pattern for digits which will show zeros - this is the one to use after the decimal point to show how many decimal places you want showing.
    This format will round the numbers either up or down depending on which is nearer.
    See example below for usage :
    import java.text.*;
    public class DoubleTest{
         public static void main(String[] args)     {
              double d = 400000.0;
              double d2 = 2.4;
              double value = (d/d2);
              DecimalFormat df1 = new DecimalFormat("#.000");
            System.out.println(df1.format(value));
    }This returns 166666.667 (i.e. 3 places after the decimal, rounded up).
    Regards,
    Fintan

  • How to determine the length of a LRAW field

    Hi
    I'm trying to write a generic persistency class that saves data in a table with a lraw field.
    As required the lraw field must be preceded by a length field of type INT2, but how can I calculate the actual length of the lraw field?
    kind regards Thomas

    Hi Martin
    I'm sorry to tell you that you are wrong. The INT2 field must contain the actual length.
    I have a table with a LRAW of 1024 bytes, but if I put 15 to the length field, then only 15 bytes are stored in the database.
    Of course I could just enter 1024 for the length, but that would wast a lot of database space - and performance.
    My class has a persistency method that inserts or updates a record in the database. The data that should be stored in the LRAW is sent to the method via a pointer (field symbol) of type X. This pointer can point at any data type.
    Something like this:
    field-symbols: <input> type x.
    field-symbols: <lraw> type x.
    *assign any field to <input>
    assign <lraw> to mydbtable-lraw_field casting.
    <lraw> = <input>.
    *here i need to determine the length of mydbtable-lraw_field before i store the content to the database.
    By debugging I can tell that if the pointer points to a char 32 field then the length of the X pointer is 64 and if the pointer points to a timestamp then the length of the x pointer is 8, but how can I determine this length programmatically - either from the x pointer or from the LRAW?
    Best regards
    Thomas

  • Changing the size of text input field in xml style coldfusion forms

    Does anyone know how to get the size attribute of a text
    input field to work in a coldfusion xml form?
    Example: When I enter the following code and view the form in
    a browser, all of the fields are the exact same size.
    <cfform format="xml" name="testingform" method="post">
    <cfformgroup type="horizontal">
    <cfinput type="text" name="first_name" size="10"
    label="First Name">
    <cfinput type="text" name="middle_init" size="2"
    label="Middle Initial">
    <cfinput type="text" name="last_name" size="20"
    label="Last Name">
    </cfformgroup>
    </cfform>

    Indeed a mistake in the Coldfusion engine. Or is there some
    reason for it? In any case, you should report it.
    Look in the source, and you will see why it happens. The XML
    form makes use of the stylesheet
    /CFIDE/scripts/css/default_style.css. There the width attribute is
    hard-coded for the cfinput element, thus
    .cfInput, .cfTextarea {
    font-size: .8em;
    font-family: inherit;
    width: 200px;
    I would replace that block with
    .cfInput {
    font-size: .8em;
    font-family: inherit;
    .cfTextarea {
    font-size: .8em;
    font-family: inherit;
    width: 200px;

  • Changing the length of a key field in a table

    Hi,
    I want to increase the length of the field from 2 to 4 in a standard SAP table and deliver it to the customers. This field is a key field in table. This field from this table is also used in view and view clusters.
    What is the implication of changing the length to the customers. The customers would have already data in this field and they should not loose any data. Will the existing data for customers remain at length 2 or do they have to do some conversion?
    Regards,
    Srini.
    Edited by: Srinivasa Raghavachar on Feb 7, 2008 12:45 PM

    hi,
    The database table can be adjusted to the changed definition in the ABAP Dictionary in three different
    ways:
    By deleting the database table and creating it again. The table on the database is deleted, the inactive
    table is activated in the ABAP Dictionary, and the table is created again on the database. Data
    existing in the table is lost.
    By changing the database catalog (ALTER TABLE). The definition of the table on the database is
    simply changed. Existing data is retained. However, indexes on the table might have to be built again.
    By converting the table. This is the most time-consuming way to adjust a structure.
    If the table does not contain any data, it is deleted in the database and created again with its new
    structure. If data exists in the table, there is an attempt to adjust the structure with ALTER TABLE. If the
    database system used is not able to do so, the structure is adjusted by converting the table.
    Field 1     Field 2,    Field 3
    NUMC,6  CHAR 8    CHAR, 60
    Field 1    Field 2       Field 3
    NUMC,6 CHAR, 8     CHAR,30
    The following example shows the steps necessary during conversion.
    Starting situation: Table TAB was changed in the ABAP Dictionary. The length of field 3 was reduced
    from 60 to 30 places.
    The ABAP Dictionary therefore has an active (field 3 has a length of 60 places) and an inactive (field 3
    still has 30 places) version of the table.
    The active version of the table was created in the database, which means that field 3 currently has 60
    places in the database. A secondary index with the ID A11, which was also created in the database, is
    defined for the table in the ABAP Dictionary.
    The table already contains data.
    Step 1: The table is locked against further structure changes. If the conversion terminates due to an
    error, the table remains locked. This lock mechanism prevents further structure changes from being
    made before the conversion has been completed correctly. Data could be lost in such a case.
    Step 2: The table in the database is renamed. All the indexes on the table are deleted. The name of the
    new (temporary) table is defined by the prefix QCM and the table name. The name of the temporary
    Step 3: The inactive version of the table is activated in the ABAP Dictionary. The table is created on the
    database with its new structure and with the primary index. The structure of the database table is the
    same as the structure in the ABAP Dictinary after this step. The database table, however, does not
    contain any data.
    The system also tries to set a database lock for the table being converted. If the lock is set, application
    programs cannot write to the table during the conversion.
    The conversion is continued, however, even if the database lock cannot be set. In such a case
    application programs can write to the table. Since in such a case not all of the data might have been
    loaded back into the table, the table data might be inconsistent.
    You should therefore always make sure that no applications access the table being converted
    during the conversion process.
    Step 4: The data is loaded back from the temporary table (QCM table) to the new table (with MOVECORRESPONDING).
    The data exists in the database table and in the temporary table after this step.
    When you reduce the size of fields, for example, the extra places are truncated when you reload the
    data.
    Since the data exists in both the original table and temporary table during the conversion, the storage
    requirements increase during the process. You should therefore verify that sufficient space is available in
    the corresponding tablespace before converting large tables.
    There is a database commit after 16 MB when you copy the data from the QCM table to the original
    table. A conversion process therefore needs 16 MB resources in the rollback segment. The existing
    database lock is released with the Commit and then requested again before the next data area to be
    converted is edited.
    When you reduce the size of keys, only one record can be reloaded if there are several records whose
    key cannot be distinguished. It is not possible to say which record this will be. In such a case you should
    clean up the data of the table before converting.
    Step 5: The secondary indexes defined in the ABAP Dictionary for the table are created again.
    Step 6: The temporary table (QCM table) is deleted.
    Step 7: The lock set at the beginning of the conversion is deleted.
    If the conversion terminates, the table remains locked and a restart log is written.
    Caution: The data of a table is not consistent during conversion. Programs therefore should not access
    the table during conversion. Otherwise a program could for example use incorrect data when reading the
    table since not all the records were copied back from the temporary table. Conversions therefore
    should not run during production! You must at least deactivate all the applications that use tables to
    be converted.
    You must clean up terminated conversions. Programs that access the table might otherwise run
    incorrectly. In this case you must find out why the conversion terminated (for example overflow of the
    corresponding tablespace) and correct it. Then continue the terminated conversion.
    Since the data exists in both the original table and temporary table during conversion, the storage
    requirements increase during conversion. If the tablespace overflows when you reload the data from the
    temporary table, the conversion will terminate. In this case you must extend the tablespace and start the
    conversion in the database utility again.
    If you shorten the key of a table (for example when you remove or shorten the field length of key fields),
    you cannot distinguish between the new keys of existing records of the table. When you reload the data
    from the temporary table, only one of these records can be loaded back into the table. It is not possible
    to say which record this will be. If you want to copy certain records, you have to clean up the table
    before the conversion.
    During a conversion, the data is copied back to the database table from the temporary table with the
    ABAP statement MOVE-CORRESPONDING. Therefore only those type changes that can be executed
    with MOVE-CORRESPONDING are allowed. All other type changes cause the conversion to be
    terminated when the data is loaded back into the original table. In this case you have to recreate the old
    state prior to conversion. Using database tools, you have to delete the table, rename the QCM table to
    its old name, reconstruct the runtime object (in the database utility), set the table structure in the
    Dictionary back to its old state and then activate the table.
    If a conversion terminates, the lock entry for the table set in the first step is retained. The table can no
    longer be edited with the maintenance tools of the ABAP Dictionary (Transaction SE11).
    A terminated conversion can be analyzed with the database utility (Transaction SE14) and then
    resumed. The database utility provides an analysis tool with which you can find the cause of the error
    and the current state of all the tables involved in the conversion.
    You can usually find the precise reason for termination in the object log. If the object log does not
    provide any information about the cause of the error, you have to analyze the syslog or the short dumps.
    If there is a terminated conversion, two options are displayed as pushbuttons in the database utility:
    After correcting the error, you can resume the conversion where it terminated with the Continue
    adjustment option.
    There is also the Unlock table option. This option only deletes the existing lock entry for the table .
    You should never choose Unlock table for a terminated conversion if the data only exists in the
    temporary table, i.e. if the conversion terminated in steps 3 or 4. table for table TAB is therefore QCMTAB.
    Hope this is helpful,Do reward.

  • How do you wrap the text on an input field with type="button"

    I want to put 2 lines of text on an input field.
    The button size is fixed at 75 and if there is more than 10 characters it truncates the text.
    The input field is defined as :
    <input type="button"
    value="CI<br>Discrepency"
    class="buttons75x75"
    onclick="javascript:callForm('ciDiscrepency');"/>
    If you can show me how, I would really appreciate it.
    -Gary

    Dug up the code I used to do this a while back:
    //The style sheet
      <style type="text/css">
        .buttonUp {
          border-style:outset;
          border-width:2px;
          width:3em;
          float:left;
          padding:2px;
          background-color:#ccc;
          text-align:center;
        .buttonDown {
          border-style:inset;
          border-width:2px;
          width:3em;
          float:left;
          padding:2px;
          background-color:#ccc;
          text-align:center;
    </style>
    //... Example buttons
      <div class="buttonUp" onmousedown="this.className='buttonDown';"
                            onmouseup="this.className='buttonUp';"
                            onclick="alert('Clicked on Small One');">He</div>
      <div class="buttonUp" onmousedown="this.className='buttonDown';"
                            onmouseup="this.className='buttonUp';">Hello</div>
      <div class="buttonUp" onmousedown="this.className='buttonDown';"
                            onmouseup="this.className='buttonUp';">Hello World</div>
      <div class="buttonUp" onmousedown="this.className='buttonDown';"
                            onmouseup="this.className='buttonUp';">Hello<br/>World</div>
      <div class="buttonUp" style="width:5em;" onmousedown="this.className='buttonDown';"
                            onmouseup="this.className='buttonUp';">Hello World</div>You could put any javascript you want on the onclick event, so you would call the javascript you previously used to submit the form and set the input name. In this example I had all the buttons be a fixed width, if you leave out the width in the style sheet then the block will snap to fill the same width as the text inside it, much like normal buttons do. The difference is, with a fixed width then text wrapping occurs automatically (like in the 3rd button) while without a defined width the div will only display a second line when the line break is added. Note the the fixed width can be over-ruled by an inline style if needed (last sample).
    The website I pointed to before has a simpler solution (less javascript events needed). An implementation for his approach would be:
    //The style sheet
      <style type="text/css">
        .button {
          border-style:outset;
          border-width:2px;
          color:#000;
          float:left;
          padding:2px;
          background-color:#ccc;
          text-align:center;
          text-decoration:none;
          display:block;
        .button:active {
          border-style:inset;
          border-width:2px;
          color:#000;
          float:left;
          padding:2px;
          background-color:#ccc;
          text-align:center;
          text-decoration:none;
          display:block;
      </style>
    //... Example buttons
      <a class="button" href="#" onclick="this.blur();alert('Now you clicked linkey');return false;">Hello<br/>World</a>Same deal here with the fixed-width vs.fit-to-content. I add the 'return false;' to the list of the onclick commands so IE doesn't make the 'link clicked' noise and the URL doesn't go to thispage.html#.
    All these buttons work in FireFox 2, IE 7, and Safari 3 if they are running in STRICT mode. The button colors and borders don't precisely match FF and IE buttons, but they are close (although they aren't close at all to Safari buttons).

  • Not show the right button in input field which data type is date

    My web dynpro has a input field. This input field is mapped with a context attribute which type is datum.
    This field is read only. I want that this field doesn't show the right button to choose the date.
    How do I solve this?
    Thanks

    Hi,
    go to the context of your view,
    to the attribute of your date,
    and set the attribute input help mode to disabled
    grtz,
    Koen

  • Where is the "not ready for input" field stored in SAP?

    Hi,
    In the tcode CT04, the 'Additional Data' tab has a field called 'not ready for input'. I want to find this value in a table. I thought it was in CABN-ATINP but this does not seem to be populated all the time.
    e.g.
    1. characteristic ABCDE has the value checked in CT04 but there is no entry in CABN-ATINP
    2. characteristic ZYXWV has the value checked in CT04 and there is an entry in CABN-ATINP
    Does anyone know:
    a) why?
    b) how to find the value for point 1 above?
    Thanks,
    Kroc.

    obviously, that is wrong.
    It is true that the ATINP value for batches which have a reference field in CT04 does not ever change but having a reference field does not necessarily mean that it should be display mode.
    Anyone know why the reference field stops the ATINP field update?
    And how does the program know that it should be 'not ready for input' when the ATINP flag is not changed?
    Thanks.

  • How to restrict the user to change/enter field value in me21n?

    Hi, Experts,
    in the me21n screen..for matkl field we need to validate the user authorization.
    if that user having the authorization then it should allow to enter value in the matkl(material group) field.
    other wise it should not allow.
    how to do this validation?
    can anybody help me on this.
    Thanks and Regards,
    venkat

    Hi Aprna,
    Thanks for your reply, but can you give some code for that.
    actually i am new to badi or userexits...
    if you can provide code it will be more helpful for me.
    Thanks in Advance,
    venkat

  • Restricting max lenfth in Input field

    Hi,
    I have use BW standard Object and this is binded to my Input field. Since BW Object is of length 60, Input field in Web Dynpro is allowing me to enter 60 Character. I want to restrict the input field to 40 so that user can not enter more than 40 character.
    Is there any possiblity to restrict input field without changing binding elemnt.
    Thanks
    Abhishek

    Other option is restrict the no of characters entered by user by binding it with context attribute of char40.
    OR 
    you could even avoid the OnEnter event of Input field if you have some more UI fields in your layout i.e.
    If you have a dropdown or a button to naviagate to other screen, then you could check there also.
    If there is no other UI, Try writing the code in wddomodify, but please be aware that wddomodify is called on evry event.
    So if you are writing code to restrict no of characters to 40 in wddomodify, write it with a conditon like :
    if lv_input is not initial.
    <  check the no of char and throw erro.>
    endif.
    lv_input has the value of input field which you could read by code wizard i.e control + F7.

  • The length of the password entry field in the BEx Analyser

    Hi,
    The password is 8 characters in the BW system.
    When users changing their newly assigned passwords. When logging into the BEx Analyser, and prompted to change the password, a password entry box is displayed, with an entry field longer then 8 characters. Some users are therefore entering passwords longer then 8 characters. This is fine when they first login, but when they try come back to the system, their logon fails.
    Can something be done to restrict the length of the password entry field in the BEx Analyser?
    Many Thanks
    Jonathan

    Hi Jonathan
    we are having the same problem - did you find a way to resolve this?  I did not find any SAP notes referring to the issue.
    Regards
    Hayley

Maybe you are looking for

  • Display month in the column

    hello...i have a report that actually need a layout of displaying the month in the column. the format as below: last month new loan (09.2008), this month new loan (10.2008), the month here will change based on the user input of the current month and

  • Memory dump in log file

    Hi, Today we had the exact scenario reported here http://support.microsoft.com/kb/974205 The server went unresponsive and the sql service had to be restarted. This sql server is the DB server for a sharepoint farm. We are running Microsoft SQL Server

  • Cost Centers not appearing in the GL Display FAGLL03

    Dear Friends, In case of a particular GL Account we find tha the Cost Centers are not getting displayed in the GL Account display. However, when we check the documents, we find that the Cost Centers have been maintained in the document entry. The use

  • Using tools in the adjustment pane

    Hi, I always use the same additional tools in the adjustment pane, "sharpness", "highlights and shadows", etc, is there any way to have these options automatically selected for each photo...I am getting tired of having to reselect them for each image

  • Apple Logo Flashing?!?!?

    I just got this IPOD MINI the battery was very low, so I tried to charge it with the USB cable. When i connected it, the apple logo appeared on the screen and just began flashing slowly. The ipod doesnt show in iTunes and i've been charging it for a