General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old July 22nd, 2002, 05:46 PM
beetle18 beetle18 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Victoria, TX
Posts: 29 beetle18 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to beetle18 Send a message via AIM to beetle18
Lightbulb New validation script completed

Hey everyone

Now I know this isn't directly related to PHP, but some people in this forum have helped me, so now I'm giving back! Here's a neato Javascript-based validator that I think you'll like. I know it doesn't replace server-side, but it's a great first-line.

Some of you may remember a post a-while back in this forum where I talked about this script some. Here it is in all it's glory.

Enjoy! Feedback is welcome!

http://www.peterbailey.net/jsdemo/

Reply With Quote
  #2  
Old July 22nd, 2002, 06:48 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
just a problem with your script

This form assumes your from the USA. it only let me put in a 5 or 9 digit post code, even tho, my post code is 4 numbers, and i had to choose a state.

just something you might wana change, like give people to option to choose a 'non american' state. but if they select a state, say new york, then it also checks the post code as 5 or 9 digits

Reply With Quote
  #3  
Old July 22nd, 2002, 06:51 PM
Lindset Lindset is offline
weirdomoderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Alta, Norway
Posts: 370 Lindset User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Lindset Send a message via AIM to Lindset
I haven't tested it for myself, but it looks very nice! Thanks for sharing!

I noticed the zip-problem too.. In Norway we don't have zip codes, we have postal codes.. For example my postal code is 9512
__________________
Best Regards,
Håvard Lindset

Reply With Quote
  #4  
Old July 22nd, 2002, 07:08 PM
beetle18 beetle18 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Victoria, TX
Posts: 29 beetle18 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to beetle18 Send a message via AIM to beetle18
Thanks for the comments.

As I mentioned on the page...this script is quite easy to add functionality to. I could easily add validation for Norway Postal codes (I'd just have to know the rules )

Not sure where I can find list of all the Zip codes per state. Perhaps www.usps.gov will have that info.

Remember, I made this script to be modular! So modify it how you need it!

Check back, if I make updates, I'll post it here.

I also plan to add validation for DECIMALS (ie decimal2|4 would require 2 digits before the decimal, and 4 digits after)

Have suggestions for any other universal or semi-universal datatypes?

Reply With Quote
  #5  
Old July 22nd, 2002, 11:23 PM
Lindset Lindset is offline
weirdomoderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Alta, Norway
Posts: 370 Lindset User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Lindset Send a message via AIM to Lindset
I have a feature-idea.. what about giving changing the background-color of the input field that has an error? Make it light-red or something.. (not too far from white, just give it a red tint).. the option to change color should be available too

Reply With Quote
  #6  
Old July 23rd, 2002, 01:43 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
thats a cool idea, that could work really nicely

Reply With Quote
  #7  
Old July 23rd, 2002, 08:14 AM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
What you could actually do is let users specify their own postcode/state validation rules so they can customize it. then you could just use the eval() function to check it...something like this:

<script language="JavaScript">

var rule="pcode.value.length == 4 && pcode.value >= 2000";

function checkPCode(pcode)
{
if(eval("rule"))
// OK
else
// Failed
}
</script>

you get the idea...just a way to customize it

Reply With Quote
  #8  
Old July 23rd, 2002, 08:21 AM
beetle18 beetle18 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Victoria, TX
Posts: 29 beetle18 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to beetle18 Send a message via AIM to beetle18
True, but this script is intended for web authors, not the general public of users. I really don't want to start the complexities of generating accurate regular expressions based on user input. A good idea, but not sure I'll use it here.

I'm working on the field coloring now....

OH, I did find the ZIP code data I needed to validate the Zip Code vs the State, but I'd have to pay for it... So that will be on hold for a bit...

Thanks for the comments! Keep em comin!

Reply With Quote
  #9  
Old July 23rd, 2002, 01:31 PM
beetle18 beetle18 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Victoria, TX
Posts: 29 beetle18 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to beetle18 Send a message via AIM to beetle18
Exclamation Update!

Ok, I've worked on this a bit, and have the new version ready

What's new:
1) Validates decimals (thats floats to you programming geeks ) within any rules
2) Validates money (US or similar currency) flexible formats
3) Provides coloring for error fields via CSS (thx for the idea Havard )


Enjoy!

Reply With Quote
  #10  
Old July 24th, 2002, 04:12 PM
beetle18 beetle18 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Victoria, TX
Posts: 29 beetle18 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to beetle18 Send a message via AIM to beetle18
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 beetle18 : July 24th, 2002 at 04:17 PM.

Reply With Quote
  #11  
Old July 24th, 2002, 05:00 PM
Lindset Lindset is offline
weirdomoderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Alta, Norway
Posts: 370 Lindset User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Lindset Send a message via AIM to Lindset
It seems like it's trying to validate the input when I click on the hotscripts rate submit button

Reply With Quote
  #12  
Old July 24th, 2002, 05:16 PM
beetle18 beetle18 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Victoria, TX
Posts: 29 beetle18 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to beetle18 Send a message via AIM to beetle18
Woopsie....sorry about that. I think my cut & pasting got a bit over-zealous or something. Should work now.

Reply With Quote
  #13  
Old July 24th, 2002, 06:26 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
very good! i have one last suggestion, for the us states and post code, you should make a seperate file, containing variables for the postcode length and an array of the states, that means people can easily modify your code

Just an idea

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > New validation script completed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway