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
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.