Jump to content

Jump to anchor after form validation


gingerbraid

Recommended Posts

Hi, I would really appreciate your help on this. I've seen a similar post here, but I still couldn't figure my problem out. I have a page with two nested forms; the inner has a text input field where the user enters an ID and then clicks on a "Preview" button to upload information for that ID from the database onto another section of the form. This upload must take place before hitting "Save" to submit the main form.

I have a [rather complex] validation code on form submission. If the validation fails, I want to reload the page at a specific anchor. Problem is, the form jumps to the anchor only when Save is clicked twice. I understand that some kind of refresh needs to be done.

Does anyone know how to implement that refresh offhand, or do you need code to illustrate?

TIA.
Link to comment
https://forums.phpfreaks.com/topic/9794-jump-to-anchor-after-form-validation/
Share on other sites

Anybody???

Clarification: What I'm doing is SERVER-SIDE validation code, and I want to reload the form on the client-side at a specific anchor if the validation was unsuccessful.

I have partially figured it out: The anchor doesn't work because the form is inside a function in a different class; the main class (which $_SERVER{"PHP_SELF"] refers to) performs validation and then calls a function in another class, which prints the form. Thus, the anchor is not found and, therefore, not redirected. Can anyone suggest a workaround?

Much appreciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.