javascript - Question on tabbing to next NON-READONLY field -
on blur of field1, field2 set readonly cursor on page defaults field2 , cursor located @ end of value , when user clicks backspace button value can erased. ability have cursor move next non-readonly or enabled field on page. do-able jquery?
any help/direction appreciated. thank you.
here code:
[code] $(function() { $("#artransferform\\:fromaccountamt").blur(function() { var origaccountamount = $("#artransferform\\:fromaccountamt").val(); var fromaccountamount = $("#artransferform\\:fromaccountamt").val(); // call validation "r2" function var modfromaccountamount = r2(fromaccountamount); //alert("modfromaccountamount = " + modfromaccountamount); fromaccountamount = $("#artransferform\\:fromaccountamt").val(modfromaccountamount).val(); //alert ("modified fromaccountamount = " + fromaccountamount); if (modfromaccountamount != "n.an") { var firstchar = fromaccountamount.charat(0); var fromacctamtlen = $("#artransferform\\:fromaccountamt").val().length; if (firstchar == "-") { var revfromacctamt = fromaccountamount.substring(1, fromacctamtlen); $("#artransferform\\:toaccountamt").val(revfromacctamt); $("#artransferform\\:toaccountamt").attr("readonly", "readonly"); } else { $("#artransferform\\:toaccountamt").val("-"+fromaccountamount); $("#artransferform\\:toaccountamt").attr("readonly", "readonly"); } } else { $("#artransferform\\:fromaccountamt").val(origaccountamount); $("#artransferform\\:fromaccountamt").select(); alert("invalid amount format. use ##.## (no commas or $ sign)"); } }); }); [/code]
have tried modifying tabindexes onblur, before return true, control cursor goes? it's kind of hack, there go.
also, use delegated event (perhaps on form) intercept , return false on keypress events modify value of readonly input. like:
$('#artransferform *[readonly]').live("keypress", function(event) { // compare keycode blacklist: backspace, perhaps delete too? if(bkeyisblacklisted) { event.preventdefault(); return false; } });
(note: pretty pseudocodeonous. you'll want double-check syntax sizzle's attribute selectors, jquery's event delegation signature. , real careful how wide cast "no keys" net: try avoid disallowing copy , other operations performed keyboard shortcuts. need check modifier key distinguish between user trying type "c" , ctrl+c.
which browser(s) testing in?
Comments
Post a Comment