View Full Version : event.returnValue=false; equivalent?
dehian
03-09-2010, 06:26 AM
Hi,
i'd like to prevent key pressing when some keys are pressed
in html/javascript i did this like that for example
<input type="text" onkeydown="if(event.keyCode==8)event.returnValue=false;">
how could i do this on an inputtext in OL?
Thanks
tglines
03-09-2010, 10:16 AM
Maybe something like this?
<handler name="onkeydown" reference="lz.Keys" args="k">
<![CDATA[
if (k == 13) this.doSomething();
]]>
</handler>
dehian
03-10-2010, 05:37 AM
Maybe something like this?
<handler name="onkeydown" reference="lz.Keys" args="k">
<![CDATA[
if (k == 13) this.doSomething();
]]>
</handler>
Thanks but it would better be something like this
<handler name="onkeydown" reference="lz.Keys" args="k">
<![CDATA[
if (k == 8) this.cancelEvent(); //avoid backspace
]]>
</handler>
do you see what i mean?
tglines
03-10-2010, 06:03 AM
Maybe you could use the 'pattern' attribute
<inputtext pattern="[a-zA-Z0-9]*" >
but I'm not sure how that would handle the backspace, probable not as you want. Just a guess on my part.
By the way, although the pattern looks like a regexp (and it is), currently only the expression [ ]* enclosing a set of characters or character ranges, preceded by an optional "^", is supported. examples: [0-9]* , [a-zA-Z0-9]*, [^0-9]*.
dehian
03-10-2010, 11:50 PM
thanks but it doesn't do the trick
the only way i found was to set attribute enabled to false on keydown and then back to true onkeyup but that's not very clean
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.