As I am developing a solution for Insurance industry I have some form where huge data entry required. There are plenty of data entry operator who entry data in the form. As they are currently using oracle form where enter key work like tab in windows application. So my department head told me make data entry form like oracle form where operator will use enter key like tab as it is there practice. So I used javascripts and jquery for solving this problem.
<script type="text/javascript">
$(document).ready(function(){
$("input").not( $(":button") ).keypress(function (evt) {
if (evt.keyCode == 13) {
iname = $(this).val();
if (iname !== 'Submit'){
var fields = $(this).parents('form:eq(0),body').find('button, input, textarea, select');
var index = fields.index( this );
if ( index > -1 && ( index + 1 ) < fields.length ) {
fields.eq( index + 1 ).focus();
}
return false;
}
}
});
});
</script>
Please add this scripts in your data entry page and add jquery-1.4.1.min.js in your page header link. Now enter key will work like tab but when its found button with text submit will work like button.
Hope it will work for you.
<script type="text/javascript">
$(document).ready(function(){
$("input").not( $(":button") ).keypress(function (evt) {
if (evt.keyCode == 13) {
iname = $(this).val();
if (iname !== 'Submit'){
var fields = $(this).parents('form:eq(0),body').find('button, input, textarea, select');
var index = fields.index( this );
if ( index > -1 && ( index + 1 ) < fields.length ) {
fields.eq( index + 1 ).focus();
}
return false;
}
}
});
});
</script>
Please add this scripts in your data entry page and add jquery-1.4.1.min.js in your page header link. Now enter key will work like tab but when its found button with text submit will work like button.
Hope it will work for you.
Thanks for your post.
ReplyDeleteI save my lots of time i want some modification in your code. i dont know how can u make it. in my form there are some textbox with CssClass="LabelTextBox" i don't want this in js. how can i modified it.