SitePoint Sponsor

User Tag List

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

    Missing fields highlighted

    Hi i am new to this forum so i'll keep it brief. i have 4 forms pages on my web site and they are all working fine. There is only one function i would like to have; if there are missing fields on the form, the customer is sent to my error page and then asked to go back and fill in the blank fields, so, i would really like to know how to have the blank fields highlighted when they go back.
    Hope somebody can help...
    cheers

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to generate the page dynamically on the server for this. What server-side technique are you using? ASP, PHP, JSP, ...?
    Birnam wood is come to Dunsinane

  3. #3
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not do some validation client-side with Javascript before the form is submitted? (of course you'll need to replicate the validation server-side too in case they haven't got JS enabled, but it would save a trip to the server)

    Then you can use a bit of DOM-scripting to indicate the missing fields.

  4. #4
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You guys seem to know your stuff! as far as server-side technique is concerned, i use frontpage and i downloaded the form from Matts script archive? if that answers your question?
    How do i validate client-side with Javascript? its all a bit mind boggling to me. You may have to be a little patient with me.
    Here is one of the pages i'm working on: http://www.blenheimcars1.netfirms.co...ES/PART_EX.HTM
    If you dont mind. Thanks...

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Frontpage is not a server-side scripting technique, it's just a WYSIWYG (what you see is what you get) HTML editor.

    If you have a form that needs validation, you must do so on the server. You can (and should, probably) also have client-side validation through JavaScript, because that will give most users quick feedback without a round-trip to the server. But since JavaScript can be disabled, or unsupported, you cannot rely on it. Therefore, you must also do server-side validation.

    You can't do server-side validation with HTML, because HTML is a markup language, not a programming language. Instead, you need a server-side scripting language, like ASP/VBScript, ASP.Net, PHP, or JSP. Which one to choose depends on what is already supported on your web server. ASP and ASP.Net are only available on Windows servers running IIS, while PHP and JSP can run on Windows, Unix, Linux, ... and IIS, Apache, ...

    The server-side script must look at the data posted from the form, and if there's something wrong, it will generate the form page again, but this time with the incorrect fields highlighted.

    This isn't something we can teach you to do in a few posts on a forum, though. If you don't feel like reading up on it yourself, the easiest way might be to hire someone to do it for you.
    Birnam wood is come to Dunsinane

  6. #6
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you do feel like learning a bit more about DOM-based Javascripting, check out Unobtrusive Javascript by Chris Heilmann (he's also on these forums if you need help, although I can't remember his boardname).

    There's a good section in that tutorial on form validation; but as Tommy says, even if you do have client-side validation, you must have server-side too.


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
  •