NetTalk Central

Author Topic: Forcing validation on form button press  (Read 4311 times)

Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Forcing validation on form button press
« on: May 01, 2012, 10:21:58 PM »
Hi all,

I've got a form that is just some memory variables, and I have a button that simply calls another web page when it is hit.

The problem is, The 4 memory fields need quote strict validation, i.e. required field, date checks etc., but it looks like none of these validations are being called when the button is being hit.

I changed the button type to 'Submit' but it still just goes to the other WebPage URL without running any validations.

Oh, and the validated fields start off hidden in the form until a checkbox is ticked.  They appear after the checkbox is ticked, but I don't know if the fact that they are hidden at the beginning of the WebForm is why they don't validate as normal?

Thanks,
Devan

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Forcing validation on form button press
« Reply #1 on: May 01, 2012, 11:17:57 PM »
Hi Devan,

Server Side code won't run if you have a URL on a button.

I'm wondering if you could just use the std save button which gives you the chance to validate the entries before leaving the form?

Kevin

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Forcing validation on form button press
« Reply #2 on: May 01, 2012, 11:19:39 PM »
The other option is to disable your button and set a session value to enable it once field level validation has been completed?

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11302
    • View Profile
Re: Forcing validation on form button press
« Reply #3 on: May 02, 2012, 02:40:22 AM »
yes, I agree with Kevin;

Use the "Save" button to go to the next URL. This will validate all the fields on the form, so is the quickest approach.

Cheers
Bruce

Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Re: Forcing validation on form button press
« Reply #4 on: May 02, 2012, 03:11:04 AM »
Thanks Kevin & Bruce!  I will do that.

I'll keep this tip in mind for future reference too - handy to know!  :)