SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form validation pop up?

    I have a long page on my site, and if some1 were to fill out my form wrong or correctly and press submit, the site will refresh and goto the very top of the page. My form and error/thank you message are at the bottom of the page by my form so they wouldnt be visible. Is there anyway to make the fom error/thanks div visible as a popup msg? I'm using lightwindow for images and it also works for pages. Don't know if it's possible or not to use this as the way the image is displayed, but heres a link to its examples here.

    If that isn't possible, is there a way to stop the browser from resetting all the way to the top of my page?


    If both of them dont work, any1 have a suggestion?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,702
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    If you have an identifier on the error or thanks, you can use the fragment identifier to make the page jump down to there.

    Code javascript:
    <div id="formMessage">
    ...
    </div>

    and navigate to page.html#formMessage
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how do I do that after the submit button is pressed and the page reloads though? wherre would i place it?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,702
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    That depends on how the form action is occuring.

    If the form is going back to the same page you should be able to add #formMessage to the end of the action attribute.

    Code html4strict:
    <form method="post" action="form.php#formMessage">
    ...
    </form>
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pmw57 View Post
    That depends on how the form action is occuring.

    If the form is going back to the same page you should be able to add #formMessage to the end of the action attribute.

    Code html4strict:
    <form method="post" action="form.php#formMessage">
    ...
    </form>
    its a php form, so i have this
    Code php:
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">

    but in my browser it comes up as this
    Code:
    <form action="/redo/index.php" method="post">
    So I don't know how to edit it exactly, so it becomes
    Code:
    <form action="/redo/index.php#contactform" method="post">
    do you have any idea b4 i ask in the php section?

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,702
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    <form action="<?php echo $_SERVER['PHP_SELF'];?>#contactform" method="post">
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx! worx perfectly


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •