element onkeydown event - javascript question

Status
Not open for further replies.

cookn22

Active Member
I found this script that I'd like to use. It formats input as its typed for doing phone numbers and social security numbers and such. I'm not sure I'm going to keep using it, but I wanted to see if I could get it to work with fabrik. In any case, I downloaded the dFilter.js file, renamed it to 20.js (the id of the form), and stuck it in the js folder. The instructions for the script gave this example (for social security numbers):
Code:
<input value="" type="text" onKeyDown="javascript:return dFilter (event.keyCode, this, '###-##-####');">

So, in my element I added an 'onkeydown' javascript action and put this code in the text box:
Code:
return dFilter (event.keyCode, this, '###-##-####');

Unfortunately, it doesn't work. I'm pretty new with javascript, just learning what I have to to get by, so I'm sure I'm missing something basic. I did go into my template and pasted the example field code from the script instructions and that field worked like its supposed to, which I guess means that 20.js is being loaded correctly for the form page.

Any ideas how I can get this to work for my fabrik element?
 
Change the line in your element JS to:

dFilter (e.keyCode, this, '###-##-####');

So two things - it doesn't need the 'return', and change 'event' to 'e'.

I don't know if the version I found of dFilter.js to test with is older than yours, but it doesn't seem to work too well. But at least it kinda works once you make the above changes!

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top