From 239926452f11ec2927934d3a03ccafdc3b78bee7 Mon Sep 17 00:00:00 2001
From: Zoltan Hawryluk <zhawry@torzhawry01749.local>
Date: Tue, 15 May 2012 21:08:45 -0400
Subject: [PATCH] Fixed script tags that were pointing to the wrong area.  Also
 fixed issue with IE not supporting navigator.language.

---
 shared/js/html5Forms.js                       | 10 +++-
 tests/html5Forms/24ways.org/index.html        |  8 +--
 tests/html5Forms/autofocus.html               | 18 +++---
 tests/html5Forms/brucelawson.co.uk/index.html |  4 +-
 tests/html5Forms/color.html                   |  4 +-
 tests/html5Forms/dateTime.html                |  4 +-
 tests/html5Forms/dev.opera.com/index.html     | 58 -------------------
 tests/html5Forms/example.html                 |  4 +-
 tests/html5Forms/index.html                   |  8 +--
 tests/html5Forms/miketaylr.com/index.html     |  4 +-
 tests/html5Forms/output.html                  |  4 +-
 tests/html5Forms/outputWithOnInput.html       |  4 +-
 tests/html5Forms/patternRequired.html         |  4 +-
 .../patternRequiredWithVisibleIf.html         |  4 +-
 tests/html5Forms/placeholder.html             | 16 ++---
 tests/html5Forms/range.html                   | 16 ++---
 16 files changed, 60 insertions(+), 110 deletions(-)
 delete mode 100644 tests/html5Forms/dev.opera.com/index.html

diff --git a/shared/js/html5Forms.js b/shared/js/html5Forms.js
index 381b9c1..0e452d0 100644
--- a/shared/js/html5Forms.js
+++ b/shared/js/html5Forms.js
@@ -10,7 +10,13 @@ var html5Forms = new function () {
 	
 	var globalEvent = document.addEventListener?document.createEvent("HTMLEvents"):null;
 	
-	
+	function getBrowserLanguage() {
+		var r = navigator.language;
+		if (!r) {
+			r = navigator.browserLanguage;
+		}
+		return r;
+	}
 	
 	me.init = function () {
 		var scriptNodes = document.getElementsByTagName('script');
@@ -88,7 +94,7 @@ var html5Forms = new function () {
 								!lang.match(/^(af|al|bg|big5|br|ca|cn|cs|da|de|du|el|en|es|fi|fr|he|hr|hu|it|jp|ko|ko|lt|lt|lv|nl|no|pl|pl|pt|ro|ru|si|sk|sp|sv|tr|zh)$/)){
 
 								
-								lang = navigator.language.split('-')[0];
+								lang = getBrowserLanguage().split('-')[0];
 							}
 							
 							
diff --git a/tests/html5Forms/24ways.org/index.html b/tests/html5Forms/24ways.org/index.html
index 6021d18..4fe9972 100644
--- a/tests/html5Forms/24ways.org/index.html
+++ b/tests/html5Forms/24ways.org/index.html
@@ -14,11 +14,11 @@
 		<link type="text/css" rel="stylesheet" href="../../../shared/css/useragentmanExample.css">
 		
 		<!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="validation,placeholder" data-webforms2-force-js-validation="true">
+		<script type="text/javascript" src="../../../shared/js/html5Forms.js" data-webforms2-support="validation,placeholder" data-webforms2-force-js-validation="true">
 		</script>
 		
 		
@@ -131,12 +131,12 @@ <h1>Payment form</h1>
 					
 					<li>
 						<label for=cardnumber>Card number</label>
-						<input id=cardnumber name=cardnumber type=number required>
+						<input id=cardnumber name=cardnumber type=text required>
 					</li>
 					
 					<li>
 						<label for=secure>Security code</label>
-						<input id=secure name=secure type=number required>
+						<input id=secure name=secure type=text required>
 					</li>
 					
 					<li>
diff --git a/tests/html5Forms/autofocus.html b/tests/html5Forms/autofocus.html
index aee41cc..163bb58 100644
--- a/tests/html5Forms/autofocus.html
+++ b/tests/html5Forms/autofocus.html
@@ -9,11 +9,11 @@
 		<title>HTML5 autofocus Attribute Test</title>
 		
 		<!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="autofocus" data-webforms2-force-js-validation="true">
+		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="autofocus" data-webforms2-force-js-validation="true">
 		</script>
 		 
 	
@@ -30,7 +30,7 @@
 		</div>
 		
 		
-		<form action="/testForm.php">
+		<form action="http://www.useragentman.com/testForm.php">
 			<fieldset>
 			<legend>Personal Information</legend>
 		
@@ -61,12 +61,14 @@
 				</tr>
 				
 				<tr>
-					<th>Postal/Zip Code</th>
-					<td><input type="text" name="postalCode" value="" placeholder="Required information" required="required" 
-						pattern="^([A-Za-z]\d[A-Za-z])\ {0,1}(\d[A-Za-z]\d)$"
+					<th>Zip Code</th>
+					<td><input type="text" name="postalCode" value="" required="required" 
+						pattern="(\d{5}([\-]\d{4})?)" data-errormessage="This must be a valid postal code."
 					/>
-					<div class="description">Please enter a valid Canadian postal code.  Valid format is <strong>H0H 0H0</strong> where <strong>H</strong>
-					is a letter and <strong>0</strong> is a number.</div>
+					<div class="description">Please enter a valid American postal code. 
+					Valid format is <strong>nnnnn</strong> or <strong>nnnnn-nnnn</strong>
+					where <strong>n</strong>
+					is a numeric digit.</div>
 					
 					</td>
 				</tr>
diff --git a/tests/html5Forms/brucelawson.co.uk/index.html b/tests/html5Forms/brucelawson.co.uk/index.html
index 245cd7b..d42e82b 100644
--- a/tests/html5Forms/brucelawson.co.uk/index.html
+++ b/tests/html5Forms/brucelawson.co.uk/index.html
@@ -48,11 +48,11 @@
 </style>
 
 <!-- Needed for Forms Feature Detection -->
-<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+<script type="text/javascript" src="../../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 </script>
 
 <!-- Needed for Validation --> 
-<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="all" >
+<script type="text/javascript" src="../../../shared/js/html5Forms.js" data-webforms2-support="all" >
 </script>
 	
 
diff --git a/tests/html5Forms/color.html b/tests/html5Forms/color.html
index 7cd0cdb..28dd4cb 100644
--- a/tests/html5Forms/color.html
+++ b/tests/html5Forms/color.html
@@ -20,11 +20,11 @@
 		
 		
 		<!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="color" data-webforms2-force-js-validation="true">
+		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="color" data-webforms2-force-js-validation="true">
 		</script>
 		
 	
diff --git a/tests/html5Forms/dateTime.html b/tests/html5Forms/dateTime.html
index 7b0ff19..cdce881 100644
--- a/tests/html5Forms/dateTime.html
+++ b/tests/html5Forms/dateTime.html
@@ -17,11 +17,11 @@
 		
 		
 		<!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		 
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="date" data-webforms2-force-js-validation="true" data-lang="qq">
+		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="date" data-webforms2-force-js-validation="true" data-lang="qq">
 		</script>
 		
 	
diff --git a/tests/html5Forms/dev.opera.com/index.html b/tests/html5Forms/dev.opera.com/index.html
deleted file mode 100644
index e88a845..0000000
--- a/tests/html5Forms/dev.opera.com/index.html
+++ /dev/null
@@ -1,58 +0,0 @@
-<!doctype html>
-<html>
- <head>
-  <title>Examples for the article "Improve your forms using HTML5!"</title>
-  <style>
-   #validation label input:valid { background:lime }
-   #validation label input:invalid { background:red; color:white }
-   input[type=submit]:default { border:solid }
-   textarea { height:4em; width:12em }
-  </style>
-  
-  <!-- This CSS file is not necessary to use html5Widgets -->
-		<link type="text/css" rel="stylesheet" href="../../../shared/css/useragentmanExample.css">
-          <!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
-		</script>
-		
-		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../../shared/js/html5Forms.js" data-webforms2-support="validation">
-		</script>
- </head>
- <body>
- 	<div id="exampleBlurb">
-    		<p>The following is an example form taken the
-			article <a href="http://dev.opera.com/articles/view/improve-your-forms-using-html5/">Improve your forms using HTML5!</a>
-			from <a href="http://dev.opera.com">The Opera Developer Community Website</a>. 
-			
-			The only thing different from the original is that I have added
-			Weston Ruter's <code>webforms2</code> to implement HTML5 form validation
-			in browsers that don't natively support it.  This change required only
-			one <code>script</code> tag.
-			  
-			<a href="#">Back to the User Agent Man HTML5 Forms article</a>.</p>
-    	</div>
-	
-	
- 	<div id="thirdPartyExample">
-	  <h1>Examples for the article "Improve your forms using HTML5!"</h1>
-	  <p>These examples form part of the article
-	   <a href="http://dev.opera.com/articles/view/improve-your-forms-using-html5/">Improve
-	   your forms using HTML5!</a> Have fun! (To play with the examples you need to
-	   use <a href="http://www.opera.com/download/">Opera 9 or newer</a>.</p>
-	  <p>The "search" control below should be focused:</p>
-	  <form action="http://www.useragentman.com/testForm.php">
-	   <p><label>Search: <input autofocus name=search></label></p>
-	   <p><input type=submit value=Go!></p>
-	  </form>
-	  <p>The control below can be used to test "validation" of form controls:</p>
-	  <form id="validation" action="http://www.useragentman.com/testForm.php">
-	   <p><label>Name: <input required name=name></label></p>
-	   <p><label>E-mail: <input type=email required name=email></label></p>
-	   <p><label>URL: <input type=url name=url></label></p>
-	   <p><label>Comment: <textarea required name=comment></textarea></label></p>
-	   <p><input type=submit value=React!></p>
-	  </form>
-  </div>
- </body>
-</html>
\ No newline at end of file
diff --git a/tests/html5Forms/example.html b/tests/html5Forms/example.html
index 2c5794c..cb145dc 100644
--- a/tests/html5Forms/example.html
+++ b/tests/html5Forms/example.html
@@ -15,11 +15,11 @@
 		
 		
        <!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="all" data-webforms2-force-js-validation="true">
+		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="all" data-webforms2-force-js-validation="true">
 		</script>
 		
     </head>
diff --git a/tests/html5Forms/index.html b/tests/html5Forms/index.html
index f414422..e4cf183 100644
--- a/tests/html5Forms/index.html
+++ b/tests/html5Forms/index.html
@@ -38,14 +38,10 @@
                     <li>
                         <a href="bradshawenterprises.com/index.html">HTML5 Form Demo</a>
                         from <a href="http://www.bradshawenterprises.com/">Richard Bradshaw</a>'s 
-                        article <a href="http://www.bradshawenterprises.com/blog/2010/fancy-forms-html5-css3-js/">Fancy Forms: HTML5 + CSS3 – JS</a>
+                        article <a href="http://www.bradshawenterprises.com/blog/2010/fancy-forms-html5-css3-js/">Fancy Forms: HTML5 + CSS3 – JS</a>. 
+                        It is a good example of how to use CSS3 to show the validity state of the form element.
                     </li>
                     
-                    <li>
-                        <a href="dev.opera.com">Example</a> from  the article 
-						<a href="http://dev.opera.com/articles/view/improve-your-forms-using-html5/">Improve your forms using HTML5!</a>
-						from <a href="http://dev.opera.com">The Opera Developer Community Website</a>.
-                    </li>
                 </ul>
                 </ul>
 			 </fieldset>
diff --git a/tests/html5Forms/miketaylr.com/index.html b/tests/html5Forms/miketaylr.com/index.html
index f836489..34fe733 100644
--- a/tests/html5Forms/miketaylr.com/index.html
+++ b/tests/html5Forms/miketaylr.com/index.html
@@ -20,11 +20,11 @@
   </style>
   
  		<!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="all">
+		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="all">
 		</script>
   
   
diff --git a/tests/html5Forms/output.html b/tests/html5Forms/output.html
index 77f38f8..41d1030 100644
--- a/tests/html5Forms/output.html
+++ b/tests/html5Forms/output.html
@@ -12,11 +12,11 @@
 		
 		
 		<!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="output" data-webforms2-force-js-validation="true">
+		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="output" data-webforms2-force-js-validation="true">
 		</script>
 		
 	</head>
diff --git a/tests/html5Forms/outputWithOnInput.html b/tests/html5Forms/outputWithOnInput.html
index 51cb4f6..7b0b012 100644
--- a/tests/html5Forms/outputWithOnInput.html
+++ b/tests/html5Forms/outputWithOnInput.html
@@ -13,11 +13,11 @@
 		
 		
 		<!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="output" data-webforms2-force-js-validation="true">
+		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="output" data-webforms2-force-js-validation="true">
 		</script>
 		
 	</head>
diff --git a/tests/html5Forms/patternRequired.html b/tests/html5Forms/patternRequired.html
index 0fe1326..72e8262 100644
--- a/tests/html5Forms/patternRequired.html
+++ b/tests/html5Forms/patternRequired.html
@@ -10,11 +10,11 @@
 		
 		
 		<!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="validation">
+		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="validation">
 		</script>
 		
 	</head>
diff --git a/tests/html5Forms/patternRequiredWithVisibleIf.html b/tests/html5Forms/patternRequiredWithVisibleIf.html
index 57b427a..e218ffd 100644
--- a/tests/html5Forms/patternRequiredWithVisibleIf.html
+++ b/tests/html5Forms/patternRequiredWithVisibleIf.html
@@ -14,11 +14,11 @@
 		<script type="text/javascript" src="../../shared/js/visibleIf.js"></script>
 		
 		<!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="validation" data-webforms2-force-js-validation="true">
+		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="validation" data-webforms2-force-js-validation="true">
 		</script>
 		
 		
diff --git a/tests/html5Forms/placeholder.html b/tests/html5Forms/placeholder.html
index f74f39d..02c0da9 100644
--- a/tests/html5Forms/placeholder.html
+++ b/tests/html5Forms/placeholder.html
@@ -10,11 +10,11 @@
 		
 		
 		<!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="validation, placeholder" data-webforms2-force-js-validation="true">
+		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="validation, placeholder" data-webforms2-force-js-validation="true">
 		</script>
 		
 	</head>
@@ -64,12 +64,14 @@
 				</tr>
 				
 				<tr>
-					<th>Postal/Zip Code</th>
-					<td><input type="text" name="postalCode" value="" placeholder="Required information" required="required" 
-						pattern="^([A-Za-z]\d[A-Za-z])\ {0,1}(\d[A-Za-z]\d)$"
+					<th>Zip Code</th>
+					<td><input type="text" name="postalCode" value="" required="required" 
+						pattern="(\d{5}([\-]\d{4})?)" data-errormessage="This must be a valid postal code."
 					/>
-					<div class="description">Please enter a valid Canadian postal code.  Valid format is <strong>H0H 0H0</strong> where <strong>H</strong>
-					is a letter and <strong>0</strong> is a number.</div>
+					<div class="description">Please enter a valid American postal code. 
+					Valid format is <strong>nnnnn</strong> or <strong>nnnnn-nnnn</strong>
+					where <strong>n</strong>
+					is a numeric digit.</div>
 					
 					</td>
 				</tr>
diff --git a/tests/html5Forms/range.html b/tests/html5Forms/range.html
index ea51a00..62c3bed 100644
--- a/tests/html5Forms/range.html
+++ b/tests/html5Forms/range.html
@@ -12,11 +12,11 @@
 		
 		
 		<!-- Needed for Forms Feature Detection -->
-		<script type="text/javascript" src="../../html5Forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
+		<script type="text/javascript" src="../../shared/js/modernizr.com/Modernizr-2.5.3.forms.js">
 		</script>
 		
 		<!-- Needed for Validation --> 
-		<script type="text/javascript" src="../../html5Forms/shared/js/html5Forms.js" data-webforms2-support="validation,range" data-webforms2-force-js-validation="true">
+		<script type="text/javascript" src="../../shared/js/html5Forms.js" data-webforms2-support="validation,range" data-webforms2-force-js-validation="true">
 		</script>
 		
 	</head>
@@ -78,12 +78,14 @@
                     </tr>
 				
 				<tr>
-					<th>Postal/Zip Code</th>
-					<td><input type="text" name="postalCode" value="" placeholder="Required information" required="required" 
-						pattern="^([A-Za-z]\d[A-Za-z])\ {0,1}(\d[A-Za-z]\d)$"
+					<th>Zip Code</th>
+					<td><input type="text" name="postalCode" value="" required="required" 
+						pattern="(\d{5}([\-]\d{4})?)" data-errormessage="This must be a valid postal code."
 					/>
-					<div class="description">Please enter a valid Canadian postal code.  Valid format is <strong>H0H 0H0</strong> where <strong>H</strong>
-					is a letter and <strong>0</strong> is a number.</div>
+					<div class="description">Please enter a valid American postal code. 
+					Valid format is <strong>nnnnn</strong> or <strong>nnnnn-nnnn</strong>
+					where <strong>n</strong>
+					is a numeric digit.</div>
 					
 					</td>
 				</tr>
