<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,6 +3,8 @@
  
  I am no javascript pro so feel free to improve it and let me know. 
 */
+
+
 var AutoJumpToNextOnLength = Behavior.create({
   initialize: function(inputLength)
   {
@@ -12,25 +14,39 @@ var AutoJumpToNextOnLength = Behavior.create({
   },
   onkeydown: function(e)
   {
-    // Stops extra characters being entered    
-    if (this.keyRange.include(e.keyCode)) {
-      return !(this.element.getValue().length &gt;= this.inputLength);
-    } else {
-      return true;
-    }
+      // Detect if there is selected text, if there is remove that selected text now.
+      selection = this.element.getValue().substring(this.element.selectionStart, this.element.selectionEnd).length
+
+      if (selection == 0) {
+	  // Stops extra characters being entered    
+	  if (this.keyRange.include(e.keyCode)) {
+	      return !(this.element.getValue().length &gt;= this.inputLength);
+	  } else {
+	      return true;
+	  }
+      }
   },
   onkeyup: function(e)
   {
-    if (this.keyRange.include(e.keyCode) &amp;&amp; (this.element.getValue().length == this.inputLength)) {  
-      try {
-        this.element.next().focus();
-      } catch(err) {
-        // No next field 
-        return false;
-      }
-    }
+      // Detect if there is selected text, if there is remove that selected text now.
+      selection = this.element.getValue().substring(this.element.selectionStart, this.element.selectionEnd).length
+
+      if (selection == 0) {
+
+	      if (this.keyRange.include(e.keyCode) &amp;&amp; (this.element.getValue().length == this.inputLength)) {  
+		  try {
+		      this.element.next().focus();
+		      this.element.next().select();
+		  } catch(err) {
+		      // No next field 
+		      return false;
+		  }
+	      }
+	  }
   }
 });
 
+
+
 Event.addBehavior({'.day_field, .month_field, .hour_field, .minute_field, second_field' : AutoJumpToNextOnLength(2)});
 Event.addBehavior({'.year_field' : AutoJumpToNextOnLength(4)});</diff>
      <filename>javascripts/date_time_field_autotab.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3332d139c9f560b8a87c3cbb958705c7e5c0095f</id>
    </parent>
  </parents>
  <author>
    <name>Michael Pope</name>
    <email>michael@dtcorp.com.au</email>
  </author>
  <url>http://github.com/adzap/date_time_text_field_helpers/commit/1aced8dcf53bf047e2fdb8c8ca9ba5fe7ee5b592</url>
  <id>1aced8dcf53bf047e2fdb8c8ca9ba5fe7ee5b592</id>
  <committed-date>2009-03-02T17:07:47-08:00</committed-date>
  <authored-date>2009-03-02T16:45:22-08:00</authored-date>
  <message>Allow overriding of text when there is selected text in the text field.

Signed-off-by: Adam Meehan &lt;adam.meehan@gmail.com&gt;</message>
  <tree>abd8cc2ac60400fe8c476b12ac671540789bbdf2</tree>
  <committer>
    <name>Adam Meehan</name>
    <email>adam.meehan@gmail.com</email>
  </committer>
</commit>
