bypass validation

Use this board to ask questions or have discussions with other Rich Displays users.
kswisher
Profound User
Posts: 27
Joined: Fri Oct 23, 2015 9:51 am
First Name: Ken
Last Name: Swisher
Company Name: MHC
Contact:

bypass validation

Post by kswisher »

Quick question about this option... I have a hidden button which is bound to my Enter key.

This button has its bypass validation set to "send data". Does this also skip all onChange event code as well as the validation?

My onChange event code is not working when I press enter, but if I tab out of the field it works just fine.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: bypass validation

Post by Scott Klement »

I don't think "onchange" ever does anything on a button. Users don't change buttons, they just click on them.

But, "send data" only affects submitting the screen to the server, not onchange evernts
kswisher
Profound User
Posts: 27
Joined: Fri Oct 23, 2015 9:51 am
First Name: Ken
Last Name: Swisher
Company Name: MHC
Contact:

Re: bypass validation

Post by kswisher »

Sorry for the confusion...the onChange is on a text box.

Now i am thinking this is just the timing. I created a very simply record format.

One text box with onChange:alert("onchange event fired")
1 OK button with the Enter key bound for shortcut.
The record format has onSubmit:alert("onSubmit event fired")

When I type in the textbox and use TAB...the onChange pops up the alert for "onchange event fired".

When I type in the textbox and press Enter...i get the alert for the onSubmit followed by the onChange
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: bypass validation

Post by Scott Klement »

Yes, in this case the onchange occurs after the screen is submited, so it's very possible the onchange won't fire at all.
kswisher
Profound User
Posts: 27
Joined: Fri Oct 23, 2015 9:51 am
First Name: Ken
Last Name: Swisher
Company Name: MHC
Contact:

Re: bypass validation

Post by kswisher »

So is this the intended functionality? If I use my mouse to press the OK button, the onChange fires before the onSubmit.

I need a way to ensure that the onChange has happened before the page is submitted.

I know the easy answer is to remove the Enter shortcut key and force them to click the button, which if it were my call then that would be the solution. But users are users.
SeanTyree
Profound User
Posts: 76
Joined: Fri Jan 11, 2013 6:11 pm
First Name: Sean
Last Name: Tyree
Company Name: US HealthWorks
State / Province: California
Zip / Postal Code: 91355
Country: United States
Contact:

Re: bypass validation

Post by SeanTyree »

Why not hide the OK button and remove the Enter shortcut, and create a new button with the Enter shortcut and the onClick event running your textbox onChange event code then performing a pui.click on the hidden OK button?
kswisher
Profound User
Posts: 27
Joined: Fri Oct 23, 2015 9:51 am
First Name: Ken
Last Name: Swisher
Company Name: MHC
Contact:

Re: bypass validation

Post by kswisher »

My problem is that I have about 15 different text boxes that could be changed, so i wouldn't know which one's onChange code to run.

I may be able to get away with running them all in the onSubmit.

I was just surprised that it didn't operate the same way as using the mouse, but I guess that the cursor leaving the field is what fires the onChange event.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: bypass validation

Post by Scott Klement »

onchange is not a feature of Profound UI -- it is a feature of HTML/Web. When you assign something to the onchange property, we take whatever you've assigned and pass it to the browser, who assigns it to the browser's onchange event. So this is not something we could change. (Even if we if *could*, we wouldn't since failing to match the HTML5 specifications is bad for everyone.)

The "onsubmit" event is our invention, however. It occurs when the screen is submitted. If the screen is submitted by the enter key, it occurs during the browser's onkeyXXXX event (either onkeyup or onkeydown, I forget which) because that's when the browser tells us that the enter key was pressed. If the screen is submitted by clicking a button, it occurs during the onclick event for that button or div.

My suggestion is to move your logic from the "onchange" event and put it in the "onsubmit" event. (Or maybe put it in both places, depending on what it does.) This way the code is run in all situations.
kswisher
Profound User
Posts: 27
Joined: Fri Oct 23, 2015 9:51 am
First Name: Ken
Last Name: Swisher
Company Name: MHC
Contact:

Re: bypass validation

Post by kswisher »

Now I am fighting a different issue related to this. I changed the onsubmit of the form to run my JS, but it is not sending all of the form data back to the server.

Is there something in the framework that monitors fields and which need to be sent on a POST? Just for a simple test without my JS, I can press the Enter key and it appears to only send text box values that have changes or not blank or something weird. I am looking at the form data being submitted, and if I leave a field blank, it doesn't even show up as a form field. If i fill that in and press Enter, then I see it.

The same thing happens if a text field does not change...i can fill it in, then press enter and it will send the form data. If i do nothing, and press enter again, it does not send that form data.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: bypass validation

Post by Scott Klement »

What do you mean by "form data"? Are you coding an HTML form somehow on your display?

If you are using the standard widgets in a Rich DIsplay, yes, it will only send the fields that have changed. The program on the server already knows the value of those that have not changed, so there's no reason to re-send them. The data is still sent to the RPG program from the Open Access hander, but there's no reason to re-send it over the network.

Is that what you mean?

Can you explain what sort of problem this is causing for you?
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests