-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi
I've been trying to apply a certain mask to a textbox value while the user is typing. Basically I'm using the onChanging event.
The point here is that I don't want to use java classes to format the value since it turns up into a server side operation, so I would like to do that in CSA (Client Side Actions) mode.
So when I type something in the textbox the javascript function called apply_mask is returning an empty string.
What is wrong with the code below? Just wondering if the javascript's regex is wrong:
.zul file
<script src="/scrips/masking.js" language="JavaScript"/> <textbox id="maskedBox" onChanging="javascript:maskedBox.value=apply_mask(event.value)" />
masking.js file
function apply_mask(v){ v=v.replace("/\D/g",""); v=v.replace("/^(\d{2})(\d)/","$1.$2") ; v=v.replace("/^(\d{2})\.(\d{3})(\d)/","$1.$2.$3") ; v=v.replace("/\.(\d{3})(\d)/",".$1/$2") ; v=v.replace("/(\d{4})(\d)/","$1-$2") ; return v; }
Thanks
Gyo
Use jQuery numeric plugin (http://plugins.jquery.com/project/Numeric)
Asked: 2009-11-17 13:51:32 +0800
Seen: 902 times
Last updated: Nov 18 '09