SitePoint Sponsor

User Tag List

Results 1 to 20 of 20

Hybrid View

  1. #1
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool Check this form validation script

    Hey everyone

    I've had this script in various stages of completion for the last year or so. I've finally put it all together and added documentation and a working demo. Feel free to use it, (just humbly give me credit )

    Feedback is welcome! Enjoy!

    Edit: Fixed! All working now!

    http://www.peterbailey.net/jsdemo/
    Last edited by beetle; Jul 22, 2002 at 13:56.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry about the bugs everyone...all good to go now.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good to see someone sharing.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  4. #4
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Updated! Now provides error coloring, validation for decimals (floats for you progamming geeks ) and better money (US) validation

    http://www.peterbailey.net/jsdemo/
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  5. #5
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Another update

    Ok, I've been toiling....

    The validator now includes:
    • Credit Card validation against card rules and Mod 10 Algorithm
    • New validation type for SELECT objects
    • Format validation without requiring field entirely
    • onSubmit() controls for confirming submission and disabling submit
    • Flexible messaging
    • Better error messages
    • Better documentation
    Enjoy!

    Note: If by chance you have aleady used a previous version (1.01, 1.11, 1.42) and you want to start using this version, please re-read the documentation, because some of the rules have changed and your page(s) will need updating.
    Last edited by beetle; Jul 24, 2002 at 13:13.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  6. #6
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just wondering what happens when people turn 100 years old.
    Last edited by Andrew-J2000; Jul 24, 2002 at 14:41.

  7. #7
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    btw I must say nice work on the js, on that site.
    Last edited by Andrew-J2000; Jul 24, 2002 at 14:41.

  8. #8
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Wondering if...

    Hi

    I was wondering if there is anyway to ensure that some data is entered into a TEXTAREA (ie. not left blank) using your script?

    Thanks.

    Mak.

  9. #9
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just do this

    if (document.all['obj'].value=='')
    {
    alert('enter some data');
    return false;
    }

    and replace obj with the name or od of the object that needs to be filled

  10. #10
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes! Read the documentation included in the .js file! It's all there! But yes, the 'blank' check is valid for TEXTAREA objects
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  11. #11
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Hi

    Thanks for that.

    I am also looking to have something that:

    1. Allows me to check that an "Accept Terms & Conditions" clause in a form is ticked. With it, users must explicitly signal their acceptance of the terms/conditions (by checking a box), before he/she can submit the form.

    2. Allows me to make sure an important field within the form is filled out correctly, by requiring that the user fills it out twice.

    Can anyone help?

    Thanks.

    Mak.

  12. #12
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PLEASE!! If you are going to use my validation script, read the documentation! It took me quite some time to put it together, and I didn't do that so everyone could ask questions that are covered by it.
    </rant>

    Ok, to answer your question, you can validate a checkbox with my validator. See the radio button example on my demo page. http://www.peterbailey.net/jsdemo

    Thank you for giving a new idea for validation. I will get to work on an 'equalto' validation type, which is common is password data entry. I'll post here when it has been added.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  13. #13
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, gosh, calm down. this one thing I hate about some people and especially academics. 'Everything is covered in the docs' people.. students get afraid to ask them after some time 'cos they get ****ty responses like this. Fair enough if it's in your documentation, but it's not exactly a small document and I may have missed it.

  14. #14
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you saying you hate me?

    Is there a student/teacher relationship here?

    You should never try to interpret feelings from written text. It just can't be done, so don't bother trying.

    Emoticons help, so pay attention to those, like the at the end of my rant SHOULD have let you know that I was indeed calm and ok with your question.

    Seriously, I was a bit surprised by your question, becuase you can very plainly see just from looking at the demo page that my script would accomodate your need. I would just appreciate it if you were somewhat familiar with it's capabilities before asking questions without regard

    Cheers

    P.S. For the record, you may contact me with any questions, and I promise I won't get mad
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  15. #15
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The number of times I've posted a "you can't assume feelings" response is unbelievable.



    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  16. #16
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Hi

    Ok.. another few questions:

    1. Today (3 August 2002), I downloaded your latest revision of the validate.js file. I implemented the 'equalto' on a couple of fields and it seemed to work. Then, however, when I try to submit a form that has some errors remaining, I get a message popping up saying 'fnselect' a few times, then the actual message that should be displayed: i.e. "you have not entered your name".

    2. I have noticed in your example that at the end of some lines (in the code) you have "... / >"
    What exactly is the ending forward-slash and space for?

    3. In the documentation section, under the 'email' heading it says:

    email

    Errors if: Field does not match email format
    Syntax: <input type="text" name="Salary" alt="money" />

    Should that be ' alt="email" ' instead; or an example of email usage?

    ----

    Thanks.

    Mak.

    -----

    UPDATE:

    1. I think the 'fnselect' was a rogue 'alert' somewhere in your code.

    Still not sure about 2 and 3.

    I also noticed that when validitation messages are displayed, for example:

    "Please enter the ..."

    In the '...' part the name of the field is displayed. However, what if you want to display a more meaningful message. Eg. the field is "More about yourself", for example, but the name of the field is: name="about".

    So, instead of displaying "Please enter the about", it would say something like "Please enter more about yourself".

    Any ideas?

    Thanks.

    Mak.
    Last edited by mak-uk; Aug 4, 2002 at 17:32.

  17. #17
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heya

    #1 - Ya, looks like you got a rogue alert. Just find it and delete it. I work on it sometimes while it's live (maybe not the best idea )

    #2 - the addition ' />' at the end of standalone tags (e.g. don't require separate closing tags) is actually the new standard for XHTML, and is perfectly valid for regular HTML. I'm just trying to get used to typing it (and <br /> and <hr /> and <meta /> etc)

    #3 - Ok, I believe that there are some typos in the documentation (like you said earlier, it's long) But, good news, I'm setting up and HTML API for it (sneak peek here) so hopefully these documentation nigglies will be taken care of

    Well, about the error messages. You can change up the script how you want. Perhaps store the error message for the object in the 'label' attribute or something like that. lemme know!
    Last edited by beetle; Aug 4, 2002 at 22:49.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  18. #18
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    ----
    Well, about the error messages. You can change up the script how you want. Perhaps store the error message for the object in the 'label' attribute or something like that. lemme know!
    ----

    Hi

    I have been playing around with it a bit but still not sure how to do it

    Thanks.

    Mak.

  19. #19
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I'm pretty busy at the moment, but here's a quick idea...
    Code:
    alert(formObj.label);
    
    <input type="text" alt="blank" label="Please enter more about yourself." />
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  20. #20
    SitePoint Addict richard_h's Avatar
    Join Date
    May 2002
    Location
    London
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice validation script, I've been working on something similar although not as extensive as yours.

    It almost makes JavaScript form validation a pleasure with a reusable class!


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
  •