Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7012811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:18:16+00:00 2026-05-27T22:18:16+00:00

I have added a BasicEditField to a GridFieldManager. When I test it, it allows

  • 0

I have added a BasicEditField to a GridFieldManager. When I test it, it allows input values like 11.11.11. How can I make my BasicEditField accept only correct double numbers, like 101.1 or 123.123. That is, allow only one decimal point.

    gfm = new GridFieldManager(1, 2, 0);
    gfm.add(new LabelField(" Enter value  : "));
    bef = new BasicEditField(BasicEditField.NO_NEWLINE|BasicEditField.FILTER_REAL_NUMERIC);
    bef.setFilter(TextFilter.get(NumericTextFilter.REAL_NUMERIC));
    bef.setFilter(TextFilter.get(TextFilter.REAL_NUMERIC));
    bef.setText("1");
    bef.setMaxSize(8);
    gfm.add(bef);
    add(gfm);

i had tried everything that i can. but the problem is yet in my app. can anyone give me a proper way to design a input field tha accepts decimal numbers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:18:17+00:00Added an answer on May 27, 2026 at 10:18 pm

    finally i got the solution for a forum(forgot to copy the link)..

    here it is…

    inside my class i put the variables…

    private int maxIntDigits = -1; 
    private int maxFractDigits = -1;
    private String old;
    

    i had added a BasicEditField, bef..

    bef = new BasicEditField("","1");
    bef.setMaxSize(8);
    bef.setChangeListener(this);
    add(bef);
    

    And then in its fieldChanged().

    public void fieldChanged(Field field, int context) 
    {
    if(field==bef)
            {
                String str = bef.getText();  
                if(str.equals("")) 
                { 
                    old = ""; 
                    //return; 
                }   
                if(str.indexOf('.') == str.lastIndexOf('.')) 
                { 
                    if(str.indexOf('-') >= 0) 
                    { 
                        bef.setText(old); 
                    } 
                    if(validateIntPart(str) && validateFractPart(str)) 
                    { 
                        old = str; 
                        //return; 
                    } 
                    else 
                    { 
                        bef.setText(old); 
                    }  
                } 
                else 
                { 
                    bef.setText(old); 
                    //return; 
                } 
    }
    

    }

    and then two functions in it…

    private boolean validateIntPart(String str) { 
            if(maxIntDigits == -1) { 
                return true;  //no limit has been set 
            } 
            int p = str.indexOf('.'); 
            if(p == -1) { 
                p = str.length(); 
            } 
            int digits = str.substring(0, p).length(); 
            if(digits > maxIntDigits) { 
                return false; 
            } else { 
                return true; 
            } 
        } 
    
        private boolean validateFractPart(String str) { 
            if(maxFractDigits == -1) { 
                return true;  //no limit has been set 
            } 
            int p = str.indexOf('.'); 
            if(p == -1) { 
                return true; //if no '.' found then the fract part can't be too big 
            } 
            int digits = str.substring(p + 1, str.length()).length(); 
            if(digits > maxFractDigits) { 
                return false; 
            } else { 
                return true; 
            } 
        }         
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added and mediaplayer control to my c# application, and I can make
I have added sprites to my NSMutable Array now I'd like to get to
I have added a nice little bit of jquery which make images black and
I have added custom attribute with the code my_price with Catalog Input Type for
I have added a like button using iFrame for the site and added the
I have added the lines to the web.config to make .html files handled by
I have added a second Virtual Device to test a different screen resolution (QVGA),
i have added to my page an asp.net calendar control and i would like
I have added locations into Eclipse so I can, say, create projects from SVN
Have added the following code to my SQL query: (Note cut down version) DECLARE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.