Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    78
    Rep Power
    0
    Originally Posted by Jacques1
    So what solution are you going now with? You cannot have both.
    Ok thanks,
    No idea, the one that works best. But as none works for me, at the moment I am not going with anyone
  2. #17
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    I'm saying that it makes no sense (and it's annoying) to have a discussion with two people about two different approaches at the same time.

    First decide if you gonna have two input fields or one. Then we can discuss what you need to do to get it working.

    Two fields are more robust and easier to handle. A single field requires some work and regex magic.
  4. #18
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    78
    Rep Power
    0
    Originally Posted by Jacques1
    I'm saying that it makes no sense (and it's annoying) to have a discussion with two people about two different approaches at the same time.
    Thats correct, I am open to both, I suppose one looks more professional, but the most important is that it works, as both are understandable for the user.
    Maybe itīs better to keep talking about 2 fields in the original post in php forum not to destroy this as the regex solution can be interisting for other and not only for me:
    http://forums.devshed.com/php-develo...0t-938128.html
  6. #19
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,853
    Rep Power
    6351
    That script I put in my post, when pasted into a PHP interpreter, prints out all 3 correctly formatted prices. Note that it's a PHP script.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #20
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    78
    Rep Power
    0
    Originally Posted by ManiacDan
    That script I put in my post, when pasted into a PHP interpreter, prints out all 3 correctly formatted prices. Note that it's a PHP script.
    Thanks,
    I use php and this does not print out anything for me, only the word test:
    PHP Code:
    <?php
    $a 
    '1.457,54';
     function 
    strip($a) { 
    {   return 
    preg_replace("/^(.+?)([\.,](\d{2}))?$/e""str_replace(array(',','.'),'','\\1') . str_replace(',','.','\\2')"$a); 
    }
    echo 
    strip('123,456,78');
    #123456.78
    echo strip('123,456.78');
    #123456.78
    echo strip('123.456,78');
    #123456.78 
     
    echo $a;
     }

     echo 
    "test";
    ?>

    Comments on this post

    • ManiacDan disagrees : Why did you screw this up so badly?
  10. #21
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    830
    Rep Power
    496
    I think you should just force your user to use only one format (chose what you wish, American or European, and just stick to it): provide an example of how the amount should be formatted, for example either "1234,56" or "1234.56", and just refuse to validate any amount that does not match your format (with just a possible exception if the user enters an amount with neither a dot nor a comma, in which case it can be considered to be a round dollar or euro amount).

    There is nothing wrong, in a user interface, to force the user to to something in the correct way if this correct way is explained clearly in the interface, and this is even a very good thing to to if this can prevent any ambiguity, especially when monetary amounts are at stake.

    Of course, having two fields is perhaps even better and more robust, but I have seen many applications (including banking interfaces where you have to enter the amount you want to wire) where just one field enforcing strict rules just does the job right.
    Last edited by Laurent_R; January 18th, 2013 at 05:04 PM.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo