NetTalk Central

Author Topic: Required field issue  (Read 2739 times)

bekeland

  • Newbie
  • *
  • Posts: 37
    • View Profile
Required field issue
« on: August 07, 2008, 01:00:43 PM »
When I have a NetWebForm and I don't use the standard save button, but use a button on the form, and I have a field with the Required attribute on, it does not work.  I can click my button, which is calling another page from my server, and go right on without entering anything in my required field.  It shows the 'required' label off to the right, just as it should, but I don't have to enter anything.  Is there something else I can do to force that required field to have to be filled before it goes to the next page?  Thanks much.

Brian Ekeland

Mike Grigsby

  • Sr. Member
  • ****
  • Posts: 380
    • Yahoo Instant Messenger - onthedotsoftware
    • View Profile
    • MyHomeAssets! Software (among others)
Re: Required field issue
« Reply #1 on: August 07, 2008, 01:31:22 PM »
I don't think "required" works on a static element such as a button. I think what you need to do is make the field that must be filled in to be required.

But not knowing the circumstances, this technique should be safe:

On the button's embed, you need to set some code. In the embeds, go to Routines | [tab name] Tab | Button Name | 2. Validate: [button] Routiine | Add Server Side Code Here, add this:

 IF [Field] = '' then p_web.SetValue('alert',loc:Alert)
    loc:Invalid = '[field]'
    loc:alert = clip('Full-name:') & ' ' & p_web.site.RequiredText
    DO SendAlert
 END

I think this is about right, but I'm not at my development computer right now. Basically you're going to appropriate the code from the alerts that would be used if you were using the save button, for example.



Mike Grigsby
Credify Systems
Central Oregon, USA

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: Required field issue
« Reply #2 on: August 07, 2008, 11:09:12 PM »
Hi Brian,

The validation (field required) would typically be done when the form is Saved.

Since your button is not the Save button, the validation isn't occurring.

You could add _extra_ Save buttons to the form if necessary - but they would need to be constructed very carefully. So if you need to do this, then let me know.

Which I suppose begs the question - why you're not using the standard Save button, but another button.

Cheers
Bruce

Mike Grigsby

  • Sr. Member
  • ****
  • Posts: 380
    • Yahoo Instant Messenger - onthedotsoftware
    • View Profile
    • MyHomeAssets! Software (among others)
Re: Required field issue
« Reply #3 on: August 08, 2008, 07:11:30 AM »
Bruce, I would be very interested in learning how you suggest creating extra save buttons.
Mike Grigsby
Credify Systems
Central Oregon, USA

bekeland

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Required field issue
« Reply #4 on: August 08, 2008, 08:47:46 AM »
Mike, thanks for that code.  If I can't get that to work I'll just get what I need with a separate form.  Bruce, what I'm trying to get is a phone number in the PayPal flow of my web store checkout.  I don't get a phone number back from PayPal using ExpressCheckout.  I'm not using the Save button because I like the buttons being in the tab box with the other fields and text in a nice line, there is more than one, and they are primarily GET'ing another page, with the PayPal API call first thing in those pages.  I wanted to require the phone number entry on the next to last page after I have the buyer details from PayPal, right before they confirm the details and click the PayNow button which calls a page to notify PayPal of the sale and display the order confirmation number.  I figured the required attribute didn't work there because the PayNow button does a GET back to the server, and it didn't look like I was getting the phone number anyway, required or not.  So I may just have to do a Form that PUT's to get what I need.  Thanks for all the help.

Brian