H
henrywuxg
Hi All,
I would like to use Period Key(.) besides Tab to toggle from one
textbox to another when user is editing IP addresses, which have four
textboxes. The function in below works fine with IE5, but it has
strange problem with Firefox 1.5.0.8.
<!--
<td>IP Address
<input type="text" size="3" maxlength="3" name="ip_1"
onkeypress="return focusNext(this.form,'ip_2',event)">.
<input type="text" size="3" maxlength="3" name="ip_2"
onkeypress="return focusNext(this.form,'ip_3',event)">.
<input type="text" size="3" maxlength="3" name="ip_3"
onkeypress="return focusNext(this.form,'ip_4',event)">.
<input type="text" size="3" maxlength="3" name="ip_4"
onkeypress="return focusNext(this.form,'ip_4',event)">
</td>
-->
function focusNext(form, elemName, evt)
{
evt = (evt) ? evt : event;
var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ?
evt.which : evt.keyCode);
if (charCode == 46) {
form.elements[elemName].focus( );
return false;
}
return true;
}
// source from <<Javascript and DHTML Cookbook>>
If you try with Firefox, besides focusing to next textbox, the period
is wrongly kept in previous one.
Thanks for any help
Henry
I would like to use Period Key(.) besides Tab to toggle from one
textbox to another when user is editing IP addresses, which have four
textboxes. The function in below works fine with IE5, but it has
strange problem with Firefox 1.5.0.8.
<!--
<td>IP Address
<input type="text" size="3" maxlength="3" name="ip_1"
onkeypress="return focusNext(this.form,'ip_2',event)">.
<input type="text" size="3" maxlength="3" name="ip_2"
onkeypress="return focusNext(this.form,'ip_3',event)">.
<input type="text" size="3" maxlength="3" name="ip_3"
onkeypress="return focusNext(this.form,'ip_4',event)">.
<input type="text" size="3" maxlength="3" name="ip_4"
onkeypress="return focusNext(this.form,'ip_4',event)">
</td>
-->
function focusNext(form, elemName, evt)
{
evt = (evt) ? evt : event;
var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ?
evt.which : evt.keyCode);
if (charCode == 46) {
form.elements[elemName].focus( );
return false;
}
return true;
}
// source from <<Javascript and DHTML Cookbook>>
If you try with Firefox, besides focusing to next textbox, the period
is wrongly kept in previous one.
Thanks for any help
Henry