never trust > or < on decimal or floats. both are an in-exact representations of numbers and can have unexpected behaviors for numbers that are close to each other. i have converted my applications that use prices to store all prices in the DB in cents as integers and convert on display to the format people are used to seeing.
On Wednesday, July 24, 2013 1:58:23 AM UTC-7, 黄祥 wrote: > > hi folks, > > i have a decimal form field that validate during submit (running on web2py > 2.5.1): > > e.g. on controller > def product(): > grid=SQLFORM.grid(db.product, onvalidation=__onvalidation_product) > return locals() > > def __onvalidation_product(form): > * if form.vars.price_list >= form.vars.selling_price:* > form.errors.selling_price = 'Selling Price must Greater than Price > List' > > when i insert price_list = 3 and selling_price = 3 the notification > appears in the form field prevent the data to be inserted. i think, it > should be : when i insert price_list = 3 and selling_price = 3 the > notification not appears and the data can be inserted > > but > def __onvalidation_product(form): > * if form.vars.price_list > form.vars.selling_price:* > form.errors.selling_price = 'Selling Price must Greater than Price > List' > > when i insert price_list = 3 and selling_price = 3 the notification not > appears and the data can be insert. i think, it should be : when i insert > price_list = 3 and selling_price = 3 the notification appears to prevent > the data to be inserted > > is there any mistake in my logic or code above? > > thanks and best regards > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.