How to "force" user to enter a valid value in a TextBox

How can one create a TextBox in which the user is not able to leave (commit the value, change focus, or perform the action of another control) unless a valid value (the value to be committed) is displayed?
The following is the best I've come up with so far.
Good: It doesn't permit a value to be committed unless it is valid.
Good: It doesn't permit the focus to be changed when TAB is pressed unless it is valid.
Bad: It permits the user to perform the action associated with a button at any time.
In the following code pressing on the button prints "I've been pushed", no matter the value of the TextBoxes. Can I stop this (in general, not for specific buttons)?
class ValidTextBox extends TextBox {
  public-init var validValue:String = "";
  function isValid():Boolean {
    return (rawText == validValue);
  var isFocused = bind focused on replace {
    if (not focused and not isValid()) {
      requestFocus();
  override function commit():Void {
    if (isValid()) { super.commit(); }
    else {};
var string1:String = "" on replace { println ("String1 = '{string1}'") };
var string2:String = "" on replace { println ("String2 = '{string2}'") };
def textbox1 = ValidTextBox { text: bind string1 with inverse; promptText: "String1: enter abc"; columns: 20; validValue: "abc"; }
def textbox2 = ValidTextBox { text: bind string2 with inverse; promptText: "String2: enter def"; columns: 20; validValue: "def"; }
def aButton = Button {
  text: "Push me";
  action: function():Void { println("I've been pushed!"); }
Stage {
  scene: Scene {
    width: 250
    height: 300
    content: [ VBox { spacing: 10; content: [ textbox1, textbox2, aButton ] } ]
}

It sounds like you are looking for a concept of validation that groups items together. In days long gone Oracle used to have a product called Oracle Forms - that had field validation, record validation and block validation. So in your example if string1 and string2 were in the same persistable data object then the equivalent concept would be 'record validation'. The code in your button would say "if the record is valid print". A record is only valid if all its fields are valid.
JavaFX really provides a 'GUI toolkit'. I think you are looking for a fairly advanced binding framework - a framework that builds on the concept of field level validation. You can approximate such a thing by creating a 'validation group' class. This class would be able to have nodes added to it and have an 'isValid()' function which only returns true if all the node items are valid.

Similar Messages

  • How to force user to enter supplier/customer name in captial letters in R12

    Dear all,
    Could anyone pls advise how to force user to enter supplier/customer name in captial letters in R12? Can I do it using OA framework personalization?
    HY

    Pl post exact versions of OS and EBS.
    The ability to do this exists in forms (professional user interface) using forms personalization, but does not exist in the OAF (self-service) interface, AFAIK. See related MOS Doc 399892.1 (Is It Possible To Restrict Employee Name Entry To All Upper Case in the PUI And SSHR ?) for some details.
    Pl confirm by opening an SR with Support.
    HTH
    Srini

  • How to force users to enter their ID and password ?

    I am considering installing AirPort Extreme at our office. We don't want guests connecting to our network. is there any option/software that will force the guest to enter an ID and password to connect to our network ? This is similar to what happens at the hotels when we try to connect to hotel's network.

    How to force users to enter their ID and password?
    is there any option/software that will force the guest to enter an ID and password to connect to our network ? This is similar to what happens at the hotels when we try to connect to hotel's network.
    The AirPort Extreme does not have the features necessary to create a "splash page" that provides basic information about the company and asks users for their identity and password....like you see at most hotels.
    Basically, with an AirPort Extreme, users would have to scan to look for the name of the wireless network to join, and then enter the password to connect.
    The best that you might be able to achieve with the AirPort Extreme is create a "hidden" network, which would require that users know both the name of the wireless network and password to connect.  However, based on experience, this might be more of a hassle than anything else.
    The bottom line.....Apple really designed the AirPort routers for home use, so that might be the best place for them in most cases.

  • Force user to enter positive/negative values on certain GL Accounts

    Hi
    If I want to force the user to be only able to enter positive values for certain GL Accounts and only negative values for other accounts, how can I do this?
    Thanks
    Johan

    Hello Johan,
    I think you have posted your question to the wrong forum.
    This forum is specifically regarding the OnDemand applications like https://bi.ondemand.com
    Cheers
    Steve

  • Prompting the user to enter a valid value in an applet

    hi everyone!
    i have this code and i want to prompt the user to set a value<1000.
    this doesnt work.if i enter a value <1000 the input dialog appears again.
    whats wrong?
    public void init()
       String j = JOptionPane.showInputDialog(null, "Enter a number less than 1000 but greater than 0");
       int i = Integer.parseInt(j);
       while(i>1000||i<1)
          String k = JOptionPane.showInputDialog(null, "Enter a number less than 1000 but greater than 0");
          int y = Integer.parseInt(k);
    ....code executed while i<1000 or i>0

    Your while is looping on i, but inside you're setting
    y not i. This should work:
    do {
    String k = get input from option pane
    int i = Integer.parseInt(k);
    } while (i > 1000 || i < 1);
    In BinaryDigit's code, you won't have access to "i" after the loop. Declare it outside the loop (as you had it).
    int i = 0;
    do {
    String k = get input from option pane
    i = Integer.parseInt(k);
    } while (i > 1000 || i < 1);

  • Forcing user to enter values at table level

    Hi,
    I have created a table ztest. How to force user to enter the values for certain fields in the table which are not keys, similar to not null in RDBMS. selecting the initial values filed in SE11 populates with some default value, but it doesnt force the user to enter the value.
    Regards,
    Raghu

    Hi,
    Just check out transaction code SE54 for events.
    Go in SE54.
    Give your table name.
    Go in Environment --> Events.
    Here add the Event '01' i.e. Before saving the data.
    Give the name for event eg 'BEFORE_SAVE'.
    Click on Editor to create an include program.
    In the include program write
    form before_save.
      data: f_index like sy-tabix. "Index to note the lines
      loop at total.
        if <action> = 'N' or <action> = 'U'.
          read table extract with key <vim_xtotal_key>.
          if sy-subrc eq 0.
            f_index = sy-tabix.
          else.
            clear f_index.
          endif.
          "(make desired changes to the line TOTAL)
          "End of Modification.
          modify total.
          check f_index gt 0.
          extract = total.
          modify extract index f_index.
        endif.
      endloop.
      sy-subrc = 0.
    endform.
    Note here in field symbol 'Total' your workarea will be their. You can make necessary checks here.
    Or else you can go for making a custom transaction for your requirement.
    Regards,
    Nitin
    *Mark all helpful answers

  • How to restrict the user to enter only numeric values in a input field

    How to restrict the user to enter only numeric values in a input field.
    For example,
    i have an input field in that i would like to enter
    only numeric values. no special characters,alphabets .
    reply ASAP

    Hi Venuthurupalli,
    As valery has said once you select the value to be of type integer,once you perform an action it will be validated and error message that non numeric characters are there will be shown. If you want to set additional constraints like max value, min value etc you can use simple types for it.
    On the project structure on left hand side under local dictionary ->datatypes->simple types create a simple type of type integer
    The attribute which you are binding to value property ;make its type as simple type which you made
    Hope this helps you
    Regards
    Rohit

  • Force user to enter text if checks YES check box

    I have created a form with YES and NO check boxes.  If user checks YES, they need to provide written reason.  Is there a way to "force" user to enter text into text box if they check the YES check box?
    Thanks,
    Toyro

    Hi Jodi,
    Yes, it has to be saved as a dynamic PDF.
    Additionally, there are some name mismatches in your form so the script was failing. My script defined page 1 as 'page1' while your form defined page 1 as 'Page1'. I renamed your form page 1 to 'page1' and the script worked fine.
    I would recommend enabling the debugger in Acrobat for form developement. See Edit > Preferences and enable the following:
    I added an additional button with some script on the button 'click' event.
    The purpose is to intervene in the submission process, in your case submitting by email. With a single submit button the email dialogue fires regardless of failed form validation. By introducing a second button you can do form validation before enabling submission. The attached form has a visible button called 'submitBtn' and your original 'Submit By Email' button which is declared as 'invisible'. My 'submitBtn' is labelled 'Submit By Email'. When the button is clicked is does form validation. If validation succeeds, I call form1.page1.Button1.execEvent("click"); to submit to the email address attached to 'Button1'.
    Take a look and see if it fits your requirements.
    Steve

  • Do u know how to prompt user to enter password and validate the password?

    hi all,anyone knows how to prompt user to enter password and validate the password as well?I do not need the GUI.Can someone post the codes here?Thanks!

    hi all,anyone knows how to prompt user to enter
    password and validate the password as well?I do not
    need the GUI.Can someone post the codes here?Thanks!Codes are
    BufferedReader
    System.in
    if
    else
    System.out.

  • FV50-- Editing Option Error "Enter a valid value" Message 00002

    Hello FI experts,
    An user is trying to execute a tcode FV50 and clicking "Editing Options" to make changes to "Doc.Type option" from "Document type hidden" to "Enter with short name" under " Special functions for single screen transactions" section.
    When the user clicks SAVE button in "Accounting Editing options" screen, user is getting the the error message  "Enter a valid value".
    Can anyone tell me how to change this option and resolve this error?
    There are users they are successfully able to change it and I am even able to change the document type options without encountering this error.
    Any help on this is much appreciated!
    Thanks,
    Himadama

    Dianne,
    Thank you for your prompt response.
    The user has done modifications in FB00 but issue is still there.
    Could you elaborate more on what has to be done in this FB00 tcode?
    Thanks much.
    Thanks,
    Himadama

  • Enter a valid value error

    Hi,
    Can anyone pls. help us figure out the problem with the newly created business partner master records?  We get an "Enter a valid value" error message when the agent (user) tries to confirm the business partner in CIC.  The user got the same error after she created another bp master record.
    I created a third bp master record for the same customer but in another application server.  I didn't get an error so I asked the agent to use this bp master record instead of the first 2.  Unfortunately, the user got the abovementioned error again after editing the bp master record that I created in the original application server. 
    Hope you can help us.
    Thanks in advance,
    Theresa

    Perform theses steps
    - In LSMW read and convert only one entry from file
    - go to SM35 -> select your session with that one entry
    - select process , option process/foreground
    - choose process
    You will have that batch input run in the foreground, so you can see all the values entered to certain input fields and all the actions which take place in that screens. This way you should see which step excatly creates the error.
    Regards
    Marcin

  • Error in VA01: Message 00002 'Enter a valid value'

    Hello Experts! When I try creating a sales order in VA01 after entering the order type and other mandatory information, I get the error message (no. 002 of class 00) saying 'Enter a valid value'. When I searched other threads in SCN with the same message, I found that this is probably because of authorizations or incorrect values in user parameters. I executed SU53 immediately after the message was issued and found that the check was successful. I even checked the profile parameters for my user ID and everything seems perfect. In fact, I was able to create sales orders until two days earlier and no user settings were changed since then. I tried creating orders from other user IDs and the same message is issued.

    after entering the order type and other mandatory
        information,  I get the error message
    If possible, share here after entering which mandatory field, system was throwing this pop up error.
    G. Lakshmipathi

  • Error message - KD199 Enter a valid value when Closing the Project at CJ20N

    Hi All,
    As I am trying to close a Project at CJ20N I have faced an error "Enter a valid value for the settlement type Message no. KD199"
    I have tried to remove the settlement rules to one of its WBS element, but I could not. System shows the same message - KD1999.
    Could you pls let me know how to resolve this to close the Project.
    Thank you
    Chandu

    Hi Chandu,
    I hope you have already setlted the project, since the system will not allow you to close the project unless there is Zero balance in the project. In this case, you can live without removing the settlement rule from any of the WBS element.
    If there is any need to have this settlement rule removed, I suggest to change the settlemet profile to " Do not settle" and check once again. ( If there is any cost already posted, then repost the same to any other receiver.)
    Hope this helps,
    Srinivas Potluri

  • SM30: "Enter a Valid Value" Issue?

    When I do an SM30 to maintain a table, the cursor jumps to a field, a yes or no field, and says enter a valid value. When I cjheck the possible values for this it is N or Y, exactly like is in the field? I am not sure what SAP is giving me the message for.
    Thank-You.

    How is the yes/no field declared in the table?  Typically a yes/no or true/false field is set as a "X" for true or yes, " " for false or no.

  • Encountering Error in webadi : "&Value is invalid. Enter a valid value for the Mapping column &Column"

    We are having a custom WebADI, containing a field (Employee Name) which is a LOV.
    The LOV has ID : Person ID, Meaning : Employee name, Description : Position Name.
    There are multiple records with same Employee name but different Person ID.
    If I select an Employee in the LOV which has multiple records (through different IDs), I am getting an error in WebADI:
    "Enter a valid EMPLOYEE_NAME.
    XX is invalid. Enter a valid value for the Mapping column EMPLOYEE_NAME"
    The Query for the LOV is correct and is returning correct records.
    Any pointers on this issue highly appreciated.

    Hi,
    The problem could be with HR security profile attached to the responsibility from where you are launching the spreadsheet. Check it once.
    Thanks.

Maybe you are looking for