#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    14
    Rep Power
    0
    Hi,

    I want to validate forms. I want to check the following.
    * Has the user given a valid e-mail address?
    * remove all leading and trailing spacebar-hits
    * Check if only text has been inputted in a textfield
    * if a valid date is given
    * Check if only numbers have been inputted in an input field
    * all other checks I may have left out.

    Thanx in advance,
    Dj Mouse
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    Go and see the form validation article....

    http://hotwired.lycos.com/webmonkey/...tw=programming

    ------------------

    SR -
    shiju.dreamcenter.net

    Web developer from GOD's own country!!!!
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    14
    Rep Power
    0
    SR,

    Thank you man! I'm already checking out those lessons on webmonkey. If you have some more of these links, please send me/e-mail them to me.

    Thanx!

    Dj Mouse
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    14
    Rep Power
    0
    SR,

    I do have another question.
    I looked at the code at Webmoney and now I'm trying to build my own validatechecker with the ereg() function. Here's what I'm trying to do:

    I want the users to enter a valid "postcode".
    A postcode contains exactly 4 leasing digits and 2 trailing letters, i.e.
    1023DE or 1023 DE are valid postcodes
    ,but
    12345 SED is not valid even as HDSK 12 is not valid.

    I tried the following code, but it won't work.

    function ValidPostcode($formname) {

    if (!ereg("^[0-9]{4,4}[ t]{0,9}[[:alpha:]]{2,2}$",$formname) {
    echo "No valid postcode!";
    return false;
    } else {
    return true;
    }

    }

    Do you have any suggestions?

    Thanx,
    Dj Mouse
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 1999
    Location
    UK
    Posts
    50
    Rep Power
    16
    Hi,

    Can I make a suggestion. Everything that you have requested in your original message can be done in JavaScript. Save yourself a lot of hassle by doing it client side.

    Falcon
  10. #6
  11. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    Javascript has its plus sides but not for form field validation. I apologize if this offends someone. Using javascript to validate form fields is a newbie approach and a bad idea as a web developer.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 1999
    Posts
    114
    Rep Power
    16
    More specifically, client-side data validation is very insecure, since it is very simple for BAD PEOPLE to by-pass your validation just by turning off JavaScript. Then they can enter values into your form that can trick your server side code and/or database software into doing whatever evil things they want.

    Always do your data validation server-side.

    Now, back to the question at hand:

    djmouse, is that a space that's allowed between the digits and the letters, or is it any whitespace character (tab, space, etc.)?

Similar Threads

  1. Putting/submitting lots of forms on one page
    By rampguy in forum PHP Development
    Replies: 1
    Last Post: December 5th, 2003, 11:47 PM
  2. Forms, validating birthdate
    By Veniogenesis in forum PHP Development
    Replies: 6
    Last Post: November 29th, 2003, 02:50 PM
  3. Validating two seperate forms on a single HTML page
    By mattboy in forum HTML Programming
    Replies: 8
    Last Post: October 24th, 2003, 04:57 PM
  4. Q regarding VBScript and validating forms
    By tom-hope in forum Visual Basic Programming
    Replies: 0
    Last Post: August 17th, 2003, 10:25 AM
  5. Validating Date Fields on forms Question
    By GuruMaster in forum HTML Programming
    Replies: 4
    Last Post: June 9th, 2003, 07:57 PM

IMN logo majestic logo threadwatch logo seochat tools logo