I was listening to the coreg webinar when Dan mentioned that he couldn't figure out how to make it go to the next field when typing in with more than one field. This is useful for things like phone numbers.
I did a little search and found it, so I've decided to share it with everyone here:
You want this between your <head> Tags:
<script language="JavaScript" type="text/javascript">
function moveOnMax(field,nextFieldID){
if(field.value.length >= field.maxLength){
document.getElementById(nextFieldID).focus();
}
}
</script>
<input type="text" id="phone1" maxlength=3 size=3 onkeyup="moveOnMax(this,'phone2')"/> <input type="text" id="phone2" maxlength=3 size=3 onkeyup="moveOnMax(this,'phone3')"/> <input type="text" id="phone3" maxlength=4 size=4 />
I think he said he couldn't make it work together with livevalidation.
Glad it could help some people =) This should help with conversions a bit
Ya would be curious to see data of how much dif this makes.....in regards to forms in general......not just co-reg
Hm, seems like it doesn't work with livevalidation in IE. Works fine in Chrome/Firefox.
OK. Found one that's easy to use and works in IE!
http://www.mathachew.com/sandbox/jquery-autotab/
1. Include the JS in your page
<script type="text/javascript" src="jquery.autotab.js"></script>
<input type="text" name="inputid1" id="inputid1" maxlength="3" size="3" /> <input type="text" name="inputid2" id="inputid2" maxlength="3" size="3" /> <input type="text" name="inputid3" id="inputid3" maxlength="4" size="5" />
<script type="text/javascript">
$(document).ready(function() {
$(':input').autotab_magic();
// OR
$('#inputid1, #inputid2, #inputid3').autotab_magic();
});
</script>
You the man, shanktank!