SitePoint Sponsor |
|
User Tag List
Results 1 to 20 of 20
-
Jul 22, 2002, 11:19 #1
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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/
-
Jul 22, 2002, 15:10 #2
-
Jul 23, 2002, 02:13 #3
- 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 |=---
-
Jul 23, 2002, 11:15 #4
- 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/
-
Jul 24, 2002, 14:09 #5
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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
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.
-
Jul 24, 2002, 14:18 #6
- 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 15:41.
-
Jul 24, 2002, 14:22 #7
- 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 15:41.
-
Jul 30, 2002, 16:55 #8
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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.
-
Jul 30, 2002, 17:01 #9
- 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
-
Jul 30, 2002, 19:36 #10
- 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
-
Jul 31, 2002, 07:31 #11
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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.
-
Jul 31, 2002, 07:48 #12
- 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.
-
Jul 31, 2002, 09:10 #13
- 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.
-
Jul 31, 2002, 09:34 #14
- 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 theat 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
-
Jul 31, 2002, 09:44 #15
- 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 |=---
-
Aug 3, 2002, 10:02 #16
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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 18:32.
-
Aug 4, 2002, 23:43 #17
- 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!
-
Aug 9, 2002, 04:03 #18
- Join Date
- Dec 2001
- Location
- Midlands, UK
- Posts
- 284
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
----
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.
-
Aug 9, 2002, 05:59 #19
- 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." />
-
Aug 10, 2002, 01:13 #20
- 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