Hellos,
I'm trying to set up an ip input field in a from and am close but not so close to how I want it to behave. What I'm trying to do is:
1. separate the ip segments in to fields.
2. auto focus between the fields based on the max length (3) of the current field.
3. if a person uses "." IE "10." strip the "." out of the current field and set focus to the next segment field.
4. If a user presses [backspace] or [delete] allow the focus to shift between the fields as needed.
I'm fairly sure that this isn't too hard and somebody probably has something just like this already. I've been trying to write this myself but am still learning so it's a very slow process.
Here is what I have so far.
I learn mostly by example so if ya have a code snipit that would be great.
Thanks in advance, Danzig
I'm trying to set up an ip input field in a from and am close but not so close to how I want it to behave. What I'm trying to do is:
1. separate the ip segments in to fields.
2. auto focus between the fields based on the max length (3) of the current field.
3. if a person uses "." IE "10." strip the "." out of the current field and set focus to the next segment field.
4. If a user presses [backspace] or [delete] allow the focus to shift between the fields as needed.
I'm fairly sure that this isn't too hard and somebody probably has something just like this already. I've been trying to write this myself but am still learning so it's a very slow process.
Here is what I have so far.
Code:
<html>
<head>
</head>
<body>
<script>
function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus();
if (document.original = window.event){
if (original.keyCode == "190"||"110"){destination.focus();} }
}
</script>
<form name="ipform">
<input type="text" name="seg1" size="3"
style="font-family: Arial; font-size: 8pt; color: #333366; position: relative; width: 30"
onKeyup="autotab(this, document.ipform.seg2)" maxlength="3">.
<input type="text" name="seg2" size="3"
style="font-family: Arial; font-size: 8pt; color: #333366; position: relative; width: 30"
onKeyup="autotab(this, document.ipform.seg3)" maxlength="3">.
<input type="text" name="seg3" size="3"
style="font-family: Arial; font-size: 8pt; color: #333366; position: relative; width: 30"
onKeyup="autotab(this, document.ipform.seg4)" maxlength="3">.
<input type="text" name="seg4" size="3"
style="font-family: Arial; font-size: 8pt; color: #333366; position: relative; width: 30"
maxlength="3">
</form>
</body>
</html>
I learn mostly by example so if ya have a code snipit that would be great.
Thanks in advance, Danzig