0

How to prevent users from typing characters such as e, %, # @ and € into a doublebox?

asked 2012-09-24 10:02:52 +0800

cvarona gravatar image cvarona
554 1 6

Hi,

I've found, quite to my surprise, that it's possible to type e and % into a doublebox. It may make sense in some cases, but I'd like to know whether there is some way to prevent these characters from being typed.

Moreover, in IE it's possible to type € (even if no currency symbol is specified in the doublebox' format) as well as # and @. But for the € symbol (as long as the format allows for it) I can't imagine why should it be possible to type # and @. Is it really meant to be like that? And if so, is there any way to constrain doubleboxes so that they only accept numbers, sign marks and group and decimal separators?

In order to reproduce this just try the following in the online sandbox using IE (it also happens as of zk 6.0.1):

<doublebox format="0.00" width="150px" />

With kind regards

César Varona

delete flag offensive retag edit

6 Replies

Sort by » oldest newest

answered 2012-09-24 19:10:52 +0800

twiegand gravatar image twiegand
1807 3

César,

You could always override what keys it will accept like this:

<doublebox format="0.00" width="150px" >
	<attribute w:name="doKeyPress_">
		function(evt){
			if (!this._shallIgnore(evt, "0123456789,."))  // modify this as needed
			this.$doKeyPress_(evt);
		}
	</attribute>
</doublebox>

Regards,

Todd

link publish delete flag offensive edit

answered 2012-09-25 08:21:22 +0800

cvarona gravatar image cvarona
554 1 6

Hi,

thanx for your reply, but it still does allow for the entering of @, # and € in IE (not in FF). The _shallIgnore method explicitly accepts alt combinations (such as @, # and € in my spanish layout keyboard):

_shallIgnore: function (evt, keys) {
		var code = (zk.ie||zk.opera) ? evt.keyCode : evt.charCode;
		if (!evt.altKey && !evt.ctrlKey && _keyIgnorable(code)
		&& keys.indexOf(String.fromCharCode(code)) < 0) {
			evt.stop();
			return true;
		}
	}

so the question should read now "why does evt.altKey yield true in FF and not in IE?". I think there's definitely something wrong with this.

With kind regards

César Varona

link publish delete flag offensive edit

answered 2012-09-26 09:07:56 +0800

cvarona gravatar image cvarona
554 1 6

I've reported as a bug so that those interested in its resolution can vote for it.

link publish delete flag offensive edit

answered 2012-09-26 09:24:59 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

They Used Same thing and this is not allowing the Special Characters. See here

link publish delete flag offensive edit

answered 2012-09-26 11:09:25 +0800

cvarona gravatar image cvarona
554 1 6

I'm afraid it does, you just need IE and a keyboard layout that forces you to combine alt-gr with another key in order to type the (un)desired character.

But even if it wouldn't, the typing of non-numerical characters should be prevented per se, without resorting to custom scripts, shouldn't it?

link publish delete flag offensive edit

answered 2012-11-13 04:05:52 +0800

vincentjian gravatar image vincentjian
2245 6

Hi cvarona,

The alt-gr key is a combination of alt key and ctrl key.
You can override doKeyPress_ function to avoid this.

<zk xmlns:w="client">
<doublebox>
    <attribute name="w:doKeyPress_">
         if (evt.altKey && evt.ctrlKey)
             evt.stop();
         else
             this.$supers('doKeyPress_', arguments);
    </attribute>
</doublebox>
</zk>

Note: the code snippet is not tested.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-09-24 10:02:52 +0800

Seen: 224 times

Last updated: Nov 13 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More