limiting input form.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • canabatz
    New Member
    • Oct 2008
    • 155

    limiting input form.

    i got some small or big problem ,for now it's big :)

    i got input form for price ,the price should go like this:

    example 23.23.

    i got auction site ,it works like that : if you input a bid price that some one else already bid then your bid is getting burnt ,example:

    if i bid for 66.98 and you bid for 66.98 we both got burnt ,and if some one else is going to bid for 66.98 ,he will get burn too!

    now my serius problem is:

    if i bid for 66.98 and you will bid for 66.981 we are both well ,but in the database we both will have the same bid!!


    how do i limit the input price after the dot?

    there is maybe way in javascript maybe to check that there is only two numbers after the dot?

    please help me with that!! ,im stuck!!


    i did limit in the input form for maxlength and max size ,but it's not the way for me.
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    You can have something like decimal(5,2) in the database. IT basically allows you to enter 5 integer units and 2 decimal units.

    Allowed 234.56
    12345.67
    Not allowed : 34.5667
    123434545.78

    So you need to validate it in server side.

    One more way is to go for client side validation through java script.

    Have a regular expression for any number with 2 decimal units.

    So if user enters more units after decimal you can give a error message and make him force to enter only two units.

    Hope this was the answer you were looking for. Hope it helps

    Regards
    Dheeraj Joshi

    Comment

    • canabatz
      New Member
      • Oct 2008
      • 155

      #3
      Thnax alot!!!

      this is the answer!! :)

      Comment

      • Dheeraj Joshi
        Recognized Expert Top Contributor
        • Jul 2009
        • 1129

        #4
        It helped you?

        Regards
        Dheeraj Joshi

        Comment

        • canabatz
          New Member
          • Oct 2008
          • 155

          #5
          you pointed me to the right direction

          i need to come out with the solution with javascript!

          i most stop the user before it comes to the database!

          i got to give alert to the user before submit to the database ,im searching the net
          now for regular expression like you told me!! :)


          i need it to be like that before you can submit : example 23.23!! not like that 23.231

          i let you know when i succeed .

          thanx man!!

          Comment

          • Dheeraj Joshi
            Recognized Expert Top Contributor
            • Jul 2009
            • 1129

            #6
            This link may help you to get some Regex's

            Link

            Regards
            Dheeraj Joshi

            Comment

            • zorgi
              Recognized Expert Contributor
              • Mar 2008
              • 431

              #7
              maybe this

              Comment

              Working...