-
1. Re: How to disable backspace key in <h:selectOneMenu>
healeyb Aug 13, 2012 7:27 PM (in response to anand_lgv)Give this a try:
...
onkeydown="if (event.keyCode == 8) return false;"
Regards,
Brendan.
-
2. Re: How to disable backspace key in <h:selectOneMenu>
anand_lgv Aug 14, 2012 12:22 PM (in response to healeyb)Thanks Brendan for your reply.
Problem with this implementation is, backspace is not allowed even inside the text box. In an transaction/screen, i have 1 select drop down, 1 text box and a button. I want to the backspace to be disabled anywhere in the form except text box and text area.
Regards,
Anand
-
3. Re: How to disable backspace key in <h:selectOneMenu>
healeyb Aug 14, 2012 1:07 PM (in response to anand_lgv)Add this to the page preferably in the <h:head> section:
<h:outputScript name="jquery.js"/>
<script type="text/javascript">
//<![CDATA[
jQuery(function($) {
$(document).keydown(function(e) {
var element = e.target.nodeName.toLowerCase();
if (e.keyCode === 8 && element != 'input' && element != 'textarea') {
return false;
}
});
});
//]]>
</script>
-
4. Re: How to disable backspace key in <h:selectOneMenu>
anand_lgv Aug 14, 2012 4:37 PM (in response to healeyb)Perfect it worked. i guess there is a typo error in e.keyCode === 8, which i have changed to e.keyCode == 8. It works as expected. Thanks Brendan for your help.
-
5. Re: How to disable backspace key in <h:selectOneMenu>
healeyb Aug 14, 2012 4:40 PM (in response to anand_lgv)the triple equals is valid javascript and checks type and value so it should work. Anyway glad it works for you.