NetTalk Central

Author Topic: Validating a form when [Enter] is pressed  (Read 2747 times)

Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Validating a form when [Enter] is pressed
« on: January 22, 2012, 06:24:20 PM »
Hi all,

I have a form that has a simple validation process that calculated the total price of the line item before saving.  I have an embed in Validate:Quantity that does a simple LineTotal = Quantity * ItemPrice and works really well when the user [Tabs] off the quantity field.

I also have the same calculate process in the 'PreInsert' embed point which does the calculation when the user presses the [Save] button as soon as they enter the quantity and press the button (i.e. haven't yet tabbed off the quantity field).

All works great EXCEPT if the user types in the Quantity field and just presses [Enter], as they are wont to do.  This ends up saving the record, with the quantities etc. but the pricing calculation does not fire.

I've tried putting the calculation process in 'CompleteForm' and 'ValidateAll' etc. but to no avail - it doesn't seem to fire.

Where is the best place to ensure that the calculation is done each time the form is saved, regardless of whether the user pressed [Save] or they pressed [Enter]?

hilton

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: Validating a form when [Enter] is pressed
« Reply #1 on: January 23, 2012, 01:13:13 AM »
Hi Devan,

Try somewhere in the ValidateRecord routine.  I tend to put some final checking in there, particularly combinations of things (eg qty supplied or qty backordered must have a value).  When enter is pressed, that routine is run which in turn validates each field.

Bye,
Hilton.