Validate double number

hi all... I need to write a method that validates a user input for double -
so far I've included that it doesn't contain alphabets or other characters such as *.{}, etc
how do I ensure that my sytem doesn't crash if somebody enters an IP Address -
any help would be truely appreciated.
thx

Sorry, didn't read the question properly (that always used to get me into trouble at school). Just realised that you're trying to read a double, so you need to check for the existence of a maximum of one decimal point. Try this:
        // Assume it's valid to start
        boolean isValid = true;
        // Initialise counters
        int count = 0;
        int index = 0;
        // Loop round all characters in the input or until invald character detected
        while (index < userInput.length() && isValid) {
            // Get the next character from the user input
            char c = userInput.charAt(index);
            // Check if it's a decimal point
            if (c == 46) {
                count ++;
                // Invalid if there's been more than one
                if (count > 1) {
                    isValid = false;
            // Check if it's less than the ASCII for '0' or greater than the ASCII for '9'
            } else if (c < 48 || c > 57) {
                isValid = false;
            // Increment the character counter
            index ++;
        // Output the result
        System.out.println("Input valid: " + isValid);
    }By the way, this doesn't allow for negatives, exponentials and the like. I suspect you'll have to go down the parsing route for that.

Similar Messages

  • How to validate the number of characters in Text Entry box?

    Hi
    I have inserted a text entry box and assigned a variable (UserName) to it. Now, I need to limit the entry to a maxinum number of 20 characters. In other words, how do I validate the number of characters in the text entry box and provide feedback if it is more than 20 characters?

    Thanks.
    I have posted this as a query on the relevant post on Jim's website. I am too new to regular expressions. I hope he will help with an example as well.
    http://captivatedev.com/2012/07/31/adobe-captivate-6-x-widget-text-entry-box-validator/
    Sreekanth

  • How to validate customer number in FD32 initial screen

    I need to validate customer number in FD32 initial screen. It should allow only Payers but not sold to

    I  think  you wont get MIC no instandard SAP

  • How to read the decimal portion of a double number? (using scanner method)

    hello Java pros....
    I need to read the integer and decimal part of a double number, one independently of the other.
    I must be able to assign the integer part to a variable, and the decimal part to a different variable.
    Is there a method that does what I need directly after reading the initial value (double) ?
    or, should I include the condition to read the decimal point somehow?
    the initial value will be input from the console using a scanner method.
    lets say the number I have is 123.345
    I must be able to separate 123 from 345 and use them independently.
    thank you all!!
    al

    The scanner should read in the user input as a string, so you have "123.456". Do something like the following:
    String   doubleNumber             = "123.456";
    String[] numberParts              = doubleNumber.split("\\.");
    int       wholeNumberPortion       = Integer.parseInt(numberParts[0]);
    int       fractionalPortion        = Integer.parseInt(numberParts[1]);
    System.out.println(wholeNumberPortion  + "." +  fractionalPortion);

  • May I know how to round a double number to 2 decimal points?

    if I have a double number 135.25689951591, how can I round this number to make it output as 135.26?

    double number = 135.25689951591;
    java.text.DecimalFormat df = new java.text.DecimalFormat("#.00");
    System.out.println(df.format(number));Alll this will do is display the value 135.26, number will still hold 135.25689951591

  • Can't validate serial number?

    I am in the process of moving from a PPC based server to an Intel based server. Both running unlimited versions of OS 10.4.8.
    I saved the settings from the old server for each service by pulling the small icon just above the save button over to the desktop. Then I reloaded them into each service on the new server by dragging them into each window.
    Within a few minutes, I get a message in the Server Admin > Settings window below the serial number fields that says:
    "Invalid Serial Number: Could not validate serial number because of firewall."
    I restarted the server and dissabled the firewall and everything works, but when I reactivate the firewall it happens again.
    So, my question is, what rule in my firewall is keeping my serial number from being validated? And why would it work on my old server and not on the new one if the settings were brought over in the way I outlined above?
    I have checked the new serial number on the Intel Mac and it is correct so I know it didnt get transfered from the old one.

    I've done a clean install of the server and I didn't do any configuration other than the initial setup. The server works fine until I turn on the Firewall, then within a few minutes I get the same message again. When I restart the server it works for a few minutes and then happens again.
    Rule 00001 does not appear at the top of the list in the firewall active rules on the Intel Mac Mini server.
    When I switch back to my old PPC server running under a different serial number but the same IP address (by switching the Ethernet cable), everything is working as it always was and the rule 00001 is there as it should be.
    Both the Mac Mini and the OS X 10.4 server are new and just out of their boxes.
    This has me really frustrated. Anyone have any ideas?

  • How to use JFormattedTextField to correctly input a double number

    I tried to use JFormattedTextField and NumberFormatter classes to ask the user to enter a double number in the scientific notation. But, it seems the NumberFormatter can not support this by defaut.
    Can some one point me to any sample?
    Thanks in advance!

    Yes, but I want to regulate the user to enter the double number in correct scientific notation. That is, enter a number like 1.23E+5.
    Right now, it will be regarded as an invalid input.

  • Printed double number of copies (Invoice printing)

    Hi,
    While giving print for invoice from vf03 its printing double number of copies i.e. if i configure 3 copies in
    communication methods then it is printing 6 or 5 or 7 copies.
    Please need information where could be the problem.
    Thanks & Regards,
    Amit

    Hi Amit,
      The extra copies your getting are they blank?
    If you have used page-break option make sure there are no blank lines before it.
    Coz it will result in a blank page.
    Hope it helps!
    Much Regards,
    Amuktha.

  • Validate Serial Number

    When I start Adobe Photoshop and Premiere Elements asks me to login , it succeeds but then comes a screen - validate Serial Number : Connect to the Internet to valideren- your serial I -valideren- click the button but nothing happens . What can I do?

    You seem to be lost. This is the Pagemaker forum..

  • How can i validate input number into a Field of  type char in oracle form?

    hi.....
    can any one help me.....please...!!!?!!
    How can i validate input number into a Field of type char in oracle form?

    i have tried doing that, but still the field except numbersthere was an error in that code. it should have been
    var_num:=to_number(var_char);however, it appears that you want the entry NOT to be a number. if this is the case then try
    begin
      if to_number(:block.item) = 0 then null; end if;
      message('The entry cannot be numeric');
      raise form_trigger_failure
    exception
      when value_error then
       /* this is where you put the code you want to be run when the
          entry is non-numeric */
    end;

  • How check validate serial number

    i want check validate serial number device cisco
    how can check it

    Hi Rez,
    Just one question, did you buy that device from an authorized vendor? If so they should be able to give you the detailed that you require
    Still for your query, you can check this link for more details. You might want to contact Cisco Support for that as well.
    Cisco Serial Number Entitlement
    http://www.cisco.com/public/support/tac/SN_Cust_QandA.html
    look for a link below where you are able to contact Cisco.

  • I can't connetcting to internet when i want  validate seriale number

    why i can't connetcting to internet when i want  validate seriale number ?

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, or by a peripheral device. 
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including Wi-Fi on certain iMacs. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. Test while in safe mode. Same problem? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

  • Validate Phone Number in CRM - transaction BP

    hello, I am interested in validate the phone number inserted by the user when creating a new business partner, while using transaction BP in CRM.
    IS there any BADI or user-exit to validate this kind of data of the business partner for de BP transaction??
    Thank you a lot!

    Hello all,
    we have this same problem and have almost solve it.
    We have created a Z function module, which has been inserted in the BDT calls for event DCHCK. Our FM is rightly called and we are able to send an error message using FM 'BUS_MESSAGE_STORE'.
    Then, our problem now is: How to get the values for telephone, mobile and e-mail address?
    We need to check this data, but are not able to see it in the debugger...
    Thanks in advance and Best Regards

  • Validate month number as text

    I am trying to validate a text field so that it only accepts the month in numerical form with a leading zero if less than 10. The data type is Text Field, the value is  “User Entered - Required” and the Validation pattern is 99.
    I have the following code:
    ----- topmostSubform.Page1.DateMM::exit: - (JavaScript, client) --------------------
    if (this.isNull) {
        xfa.host.messageBox("Field cannot be blank!");
    else {
        if (xfa.event.commitKey == 2){
            if (this.rawValue >= "01" && this.rawValue <= "12") {
                xfa.host.setFocus("DateDD");
            else {
                this.rawValue = "";
                xfa.host.messageBox("Please enter month number between 01 and 12");
    ----- topmostSubform.Page1.DateMM::validate: - (JavaScript, client) ----------------
    if (this.rawValue >= "01" && this.rawValue <= "12")
        true;
    else
        this.rawValue = "";
        false;
    ----- topmostSubform.Page1.DateMM::change: - (JavaScript, client) ------------------
    if (xfa.event.commitKey == 2){
            if (this.rawValue >= "01" && this.rawValue <= "12") {
                xfa.host.setFocus("DateDD");
            else {
                this.rawValue = "";
                xfa.host.messageBox("Please enter month number between 01 and 12");
    Since the field is required, I want the message “Field cannot be blank!” to be displayed if when entered on the field and nothing is entered. If validation doesn’t pass (month from 01 to 12), delete the text and display error message. As it is now The validation seems to work, but the error messages are not showing except the “field cannot be blank”. If I enter incorrect text I get the “Field cannot be blank” twice.

    Put this code on the exit event of the field. If the user enters a single digit then a 0 will be added.. Make sure the field is a numeric firld and it is set for an integer. This will make sure the user cannot enter a letter.
    if (this.rawValue.length < 2){
    this.rawValue = "0" + this.rawValue
    if ((this.rawValue > 12) || (this.rawValue < 1)){
    app.alert("The field must conatain a value from 01 - 12")
    this.rawValue = ""
    xfa.host.setFocus(this.name)
    Paul

  • Partition Manager is creating more than double number of partitions .

    Dear Team,
    I am facing a very weird scenario .
    For one of my product , one of the section is the Partition Manager executing for the Tables . Now I am facing a problem and it is really getting difficult for me to get to the root cause and thus posting in the forum ...
    I am having two Linux systems , in one of the system, installation of the product goes fine , and partition manager is doing the partition as intended .
    In another Linux lab , ( with some extra application installed ) , the same product is failing to install , and the problem is Partition Manager is doing the partition more than double as compared to first Lab and because of this it ends up using all the space in the system .
    My Concern is do we have any global setting for this Partition Manager in the Oracle Database , and because of this I am seeing the difference in this 2 labs ..I will be really thankful for any of the inputs and suggestion ...
    With Very Best Regards,
    Shail...
    Edited by: 999908 on 13 Apr, 2013 9:27 PM

    Hello Justin,
    First of all thanks a lot for your patience ... :) , in looking into my problem ..
    But I guess it is using Oracle partitioning Concept only...I dont think , my product is using the third party partition tool ( I will recheck this once to confirm )
    What I understand is that , if for any table the number of partitions is almost thrice in one system as compared to other , then it will end up consuming more space for the table in the system where it is creating more number of partitions ...
    I guess memory usage for any table also depends on the number of partitions ( Please do correct me if I am wrong here ) , if more number of partitions are there then more memory will be consumed , I guess..With Very Best Regards,
    Shail

Maybe you are looking for

  • Safari 3.0.2 won't run after 3.0.1 worked fine

    Safari 3.0.1 was working fine for me on win xp pro after copying fonts to address text problem. I downloaded 3.0.2 and installed. the install appeared to work fine, but when I try to run safari, i get no error and it won't run. I've turned off firewa

  • Unable to create followup document

    Hi All, I am trying to create followup document from activity, but unable to get successful, actually debugged standard order maintain function module also, I  populated & followed the same in my zprogram too, but for the same values from standard pr

  • Which is better Gigabit Ethernet DP or Quicksilver SP

    Hello I'm fairly new to the Mac only been a user for 2.5 years, versus Wintel 20 years. Well a brief history I started out with a iMac G3 600MHz/1GB/40GB/CD-RW/16MB Rage 128 in April 2008 then moved onto a PowerMac G4 Quicksilver 2001 733MHz last Sep

  • How do you reduce contacts listed in Messages application?

    In the messages app, when I am typing a new message for a contact it shows every phone number, every imessage address, every im address, etc.  Is there a way to reduce the set of addresses that show up for a contact?  Or, is there a way to only list

  • JNI problem loading jpegs

    In my application I used several JPEGs as ImageIcons. My application worked great from the commandline, but stopped working when I ported it to Web Start. I load the JPEG from the jar file using the following: ClassLoader cl = this.getClass().getClas