Masked input

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
alexandr

Masked input

Post by alexandr »

Masked input allows to enter the data in certain format (dates,phone numbers, etc).
Example (123)123-123-1


zmakcw

Post by zmakcw »

Here's a good solution digitalbush.com/projects/masked-input-plugin/
If the developers have integrated into PHPmaker it would be very good.


Webmaster
User
Posts: 9425

Post by Webmaster »

Since it is JavaScript, you can do that yourself easily:

  1. Enable "Use jQuery" in Advanced Settings (no need for newer versions which always use jQuery),
  2. Put your jquery.maskedinput.js in the "phpjs" folder of your site,
  3. Include the script by Page_Head server event,

ew_AddClientScript("phpjs/jquery.maskedinput.js");

  1. Setup your masks in Startup Script, e.g. in Add page,

$("#x_YourField1").mask("99/99/9999");
$("#x_YourField2").mask("(999) 999-9999");

(Also read Server Events and Client Scripts in the help file for more info about the events.)


made

Post by made »

i have field "NUMBER"
i follow all the steps..

  1. Enable "Use jQuery" in Advanced Settings, (not necessary since v9, jQuery is always included)
  2. Put jquery.maskedinput.js in the "phpjs" folder of my site,
  3. Include the script:
    ew_AddClientScript("phpjs/jquery.maskedinput.js");
    on Page_Head server event
  4. Setup masks in client scripts-table specific-Startup Script on add page and edit page
    $("x_NUMBER").mask("99-99-9999");

but on add page or edit page nothing happens. am i missing something?


Webmaster
User
Posts: 9425

Post by Webmaster »

jQuery requires a selector, use $("#x_YourField1").


SouzaRM
User
Posts: 7
Location: Brasilia - Distrito Federal - Brazil

Post by SouzaRM »

I did it!
Was putting on the event [Client scripts - Table specific - Client script],
when the correct thing in [Client scripts - Table specific - Startup Script].


noimad1
User
Posts: 13

Post by noimad1 »

Question for you guys on this one. I followed your steps, and as far as the add/edit pages goes the mask (phone number in (999)999-999) is working fine. however, for some reason on the "view" and "list" pages, it is just showing "0" in the field. Any idea what could be causing that?


noorshiam
User
Posts: 67
Location: Surabaya - East Java - Indonesia
Contact:

Post by noorshiam »

I have followed all steps as explain above, but nothing happend on add or edit page. My field is time type, field name : "TimeIn" and setup mask like this : $("#x_TimeIn").mask("99:99");

Is that wrong?


ronaldoo
User
Posts: 3

Post by ronaldoo »

Hello, anyone knows how to do? I want it to mask phone number fields like "(xx)xxxx-yyyy". Thank you.


rodrigofaustino2
User
Posts: 28

Post by rodrigofaustino2 »

Why does not grid work with multiple lines?


kirondedshem
User
Posts: 642

Post by kirondedshem »

nothing has changed it still works as expected, the point is to include the js file in page_head so its available for use, then call your jquery to set mask on specific field.

  • got and download the zip repo from github.com/digitalBush/jquery.maskedinput
    -extract it go to demo index and see how it works, also open the index page in notepad so you see what you need to do to implement it else where, that is see what they are including when and how they are using the library

nway
-1. copy the jquery.maskedinput.min.js into some where i your project, eg i create a folder called "custom_plugin" and paste the file in there
-2. go to page_head event and paste the code below to include this file into all your files.

<script src="custom_plugin/jquery.maskedinput.min.js" type="text/javascript"></script>

-3. Now all you have to do is paste jquery in startup script of any page to initialise the input fields (refer to examples in the demo index file for how to use also refer to thier docs), for example go to your table->client scripts->add page->startup script and paste something like this.

// initialise the model field as a phone number
$("#x_Model").mask("(999) 999-9999");

-3. regenerate all files and its done, if its not working check the console log for errors

HINT:All web application libraries follow the same approach just find out what files it needs to work and include them into your project, then find out how you use the library's implementation


MBQ
User
Posts: 6

Post by MBQ »

I tried this and works well until you use an Android device.

Any options?

Thanks!


msduransti
User
Posts: 3

Post by msduransti »

Hello!

I'm new to PHP Maker and i just want to be clarified regarding the use of jquery.maskedinput.js.

what does this file contain?

thanks


Post Reply