0

I need not to focus on readonly input and when user tab it should jump to next write field.

    <input type="text" name="first"></input>
    <input type="text" name="second" readonly="readonly"></input>
    <input type="text" name="third"></input>
    <input type="text" name="fourth"></input>
    <input type="text" name="fifth" readonly="readonly"></input>
    <input type="text" name="sixth"></input>



<script>
$(document).ready( function(){
    $('input').focus(function(e) {
            var readonly = $(this).attr("readonly");
            if (readonly) {
                $(this).next('input:not([readonly])').focus();
                e.preventDefault();

            }
        });
});
</script>
2
Contributors
1
Reply
5
Views
5 Years
Discussion Span
Last Post by stbuchok
0

Try something like this (completely untested):

<script>

$('[data-nextElement]').focus(function(){
    $('#' + $(this).attr('data-nextElement')).focus();
});

</script>

...

<form>
<input type="text" id="txtText1" />
<input type="text" id="txtText2" readonly="readonly" data-nextElement="txtText3" />
<input type="text" id="txtText3" />
<input type="text" id="txtText4" />
<input type="text" id="txtText5" readonly="readonly" data-nextElement="txtText6" />
<input type="text" id="txtText6" />
<input type="text" id="txtText7" />
<input type="text" id="txtText8" readonly="readonly" data-nextElement="txtText1" />
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.