Permalink
Browse files

Merge pull request #9 from Zoramite/demo

Demo Update
  • Loading branch information...
2 parents 57ae5c0 + f5cdf92 commit 2087710c2017652086837df7ccd18a10b9ef26d6 @daspecster daspecster committed Apr 13, 2012
Showing with 66 additions and 56 deletions.
  1. +1 −1 README.md
  2. +0 −50 address.html
  3. +64 −0 demo.html
  4. +0 −4 jquery.js
  5. +1 −1 jquery.ziptastic.js
View
@@ -12,6 +12,6 @@ Can be used to query for a specific zip code.
$('#zip')
.ziptastic()
- .on('zipChange', function(country, state, city, zip) {
+ .on('zipChange', function(event, country, state, city, zip) {
// Use the data...
});
View
@@ -1,50 +0,0 @@
-<html>
- <head>
- <title>Address</title>
- <style>
- form label, form input {
- display: block;
- }
- </style>
- </head>
- <body>
- <form id="theform">
- <label for="fullname">
- Fullname:
- <input type="text" id="fullname" />
- </label>
-
- <label for="street-address">
- Address:
- <input type="text" id="street-address" />
- </label>
-
- <label for="city">
- City:
- <input type="text" id="city" />
- </label>
-
- <label for="state">
- State:
- <input type="text" id="state" />
- </label>
-
- <label for="country">
- Zip:
- <input type="text" id="country" />
- </label>
-
- <label for="zip">
- Zip:
- <input type="text" id="zip" />
- </label>
-
- <input type="submit" />
- </form>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript" src="zippidydoda.js"></script>
- <script type="text/javascript">
- $('#theform').ziptastic();
- </script>
- </body>
-</html>
View
@@ -0,0 +1,64 @@
+<html>
+ <head>
+ <title>Zip Code Lookup Demo</title>
+ <style>
+ form label, form input {
+ display: block;
+ }
+ </style>
+ </head>
+ <body>
+ <form id="theform">
+ <label for="zip">
+ Zip:
+ <input type="text" id="zip" />
+ </label>
+
+ <label for="city">
+ City:
+ <input type="text" id="city" />
+ </label>
+
+ <label for="state">
+ State:
+ <input type="text" id="state" />
+ </label>
+
+ <label for="country">
+ Country:
+ <input type="text" id="country" />
+ </label>
+
+ <input type="submit" />
+ </form>
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
+ <script type="text/javascript" src="jquery.ziptastic.js"></script>
+ <script type="text/javascript">
+ (function($) {
+ $(function() {
+ var duration = 500;
+
+ var elements = {
+ country: $('#country'),
+ state: $('#state'),
+ city: $('#city'),
+ zip: $('#zip')
+ }
+
+ // Initially hide the city/state/zip
+ elements.country.parent().hide();
+ elements.state.parent().hide();
+ elements.city.parent().hide();
+
+ // Initialize the ziptastic and bind to the change of zip code
+ elements.zip.ziptastic()
+ .on('zipChange', function(evt, country, state, city, zip) {
+ elements.country.val(country).parent().show(duration);
+ elements.state.val(state).parent().show(duration);
+ elements.city.val(city).parent().show(duration);
+ });
+ });
+ }(jQuery));
+ </script>
+ </body>
+</html>
View
Oops, something went wrong.
View
@@ -1,7 +1,7 @@
(function( $ ) {
var requests = {};
var zipValid = {
- us: /[0-9]{5}(-[0-9]{4})/
+ us: /[0-9]{5}(-[0-9]{4})?/
};
$.ziptastic = function(zip, callback){

0 comments on commit 2087710

Please sign in to comment.