SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form Validation wont work in ajax window.

    Hi All,

    Im new to all this as you are probably aware!

    I've come accross a stumbling block.

    On the following page if you try and submit the form with empty fields you get a javascript alert.

    http://www.fireworkscrazy.co.uk/stor...add.asp?id=166

    However, the same form is pulled into this page,

    http://www.fireworkscrazy.co.uk/stor...exd.asp?id=166

    cliick on the "add your own review" link at the bottom of the review section. When the page loads, if you try and submit the form empty you don't get the javascript alert.

    Can someone please explain why and if it can be resolved?

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have a more specific JavaScript question? Did you debug the code? Did you get any errors?

  3. #3
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Probably because AjaxTabs.OpenTab sticks all of the content in to the container specified using innerHTML, and doesn't do things like handle <script> tags properly.

    AjaxTabs is not a control I'm familiar with but I noticed you are using prototype, which has Ajax.Updater. In the options you can specify the evalScripts property which should properly handle the scripts you pull in.
    http://www.prototypejs.org/api/ajax/updater

    A personal note: The content you pull in with ajax seems to be essentially static when the page loads. So why use ajax at all? Why not populate those tabs using asp?

  4. #4
    SitePoint Member
    Join Date
    Feb 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi JimFraser

    As you can probably tell, im not the best coder in the world, more of a copy / paste and tweak guy.

    I could do it in asp i suppose, but really wanted to have a play with ajax to try and get to grips with it a little.

    You say im using prototype, i don't even know what that is. I didnt write the original code.

    So i'm really stuck. Any pointers would be much appreciated.

  5. #5
    SitePoint Member
    Join Date
    Feb 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I sort of get what you are saying about not running the script. In firefox it doesn't even submit the form let alone run the alert! in IE it returns the next page.


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
  •