SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Conflict between ONBLUR and ONSUBMIT in the one form?

    Is there a conflict between using ONBLUR and ONSUBMIT in the one form.

    I'm using Javascript to validate a HTML form so that the ONSUBMIT button causes the Javascript to execute.

    However, with the form, I'm using the ONBLUR stroke as well to check an existing field.

    The form works OK except for:

    If a user hits the submit button after the ONBLUR button has been reached, the javascript does not interrogate further fields.

    Any help, much appreciated.

    Code Crawler

  2. #2
    SitePoint Addict richtestani's Avatar
    Join Date
    Nov 2003
    Location
    Bridgeport
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you using onblur to validate a field?
    RichTestani
    -------------------------------
    http://www.junkdepot.com
    http://www.rareoopdvds.com | The Movie Poster Site

  3. #3
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Yes, very much so

    I have about 21 fields in the form.

    I use ONBLUR to validate one field, a money field.

    The others, I use ONSUBMIT

    Cheers

  4. #4
    SitePoint Addict richtestani's Avatar
    Join Date
    Nov 2003
    Location
    Bridgeport
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should put all your validations into functions, then call them onsubmit.
    Using onBlur to validate isnt a good idea, since it only is called when you leave that field. Ultimately I could click on each field except your money field and it would never trigger onblur.
    RichTestani
    -------------------------------
    http://www.junkdepot.com
    http://www.rareoopdvds.com | The Movie Poster Site

  5. #5
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Rich,

    But I use ONBLUR to reformat the field and show the user the resiults of that re-formating before the ONSUBMIT button is esecuted, so the user can change the contents of the field, i.e. the numbers entered, if he chooses.

    What Ineed in my code, is logic that requries the flow to return to the field after the ONBLUR field so that when the ONSUBMIT button is clicked all the subsequent fields are tested.

  6. #6
    SitePoint Addict richtestani's Avatar
    Join Date
    Nov 2003
    Location
    Bridgeport
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can still reference the field without using onBlur. I think you are thinking onBlur is the only way to talk to the field.

    You can write all this without onBlur all within a function that steps through each field and checks it's values making sure its right.

    What are you reformatting? Why does the user care how it looks? I am not totally sure what is happening on your site, but most reformatting can be done server side and resent to the next page.
    RichTestani
    -------------------------------
    http://www.junkdepot.com
    http://www.rareoopdvds.com | The Movie Poster Site


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
  •