Title: Custom Field Types
Last modified: August 30, 2016

---

# Custom Field Types

 *  Resolved [dang621](https://wordpress.org/support/users/dang621/)
 * (@dang621)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-field-types/)
 * I was able to add a new custom field (“Profit”) but now I want it to replicate
   the functionality of the “Price” field.
 * How do I code it so that when the user puts their cursor in the field, the currency
   symbol automatically shows up and the 000’s are separated by commas? I basically
   want to replicate the “Price” field functionality for this new “Profit” field
   I’ve created.
 * Also, I have this other field that I need to force to only accept integers. How
   do I accomplish this?
 * Thanks
 * [https://wordpress.org/plugins/wpadverts/](https://wordpress.org/plugins/wpadverts/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/custom-field-types/#post-6833129)
 * Hi,
    1. this quite more advanced, you will need a JavaScript file and following
   code inside it
 *     ```
       jQuery(function($) {
           if($("#your_field_name").length > 0) {
               $("#your_field_name").autoNumeric('init', adverts_currency);
           }
       });
       ```
   
 * Just replace your_field_name with actual name of your custom field. Ideally you
   should enqueue this file on your site as explained here [https://codex.wordpress.org/Function_Reference/wp_enqueue_script](https://codex.wordpress.org/Function_Reference/wp_enqueue_script).
 * Last note the adverts_currency you can replace with our own params as explained
   here [https://github.com/BobKnothe/autoNumeric](https://github.com/BobKnothe/autoNumeric)
 * 2. You can add integer validator similarly as is_required validator
 *     ```
       $form["field"][] = array(
               "name" => "my_custom_field",
               "type" => "adverts_field_text",
               "order" => 25,
               "label" => "Custom Field",
               "is_required" => true,
               "validator" => array(
                   array( "name" => "is_required" ),
                   array( "name" => "is_integer" )
               )
           );
       ```
   
 * although this validator has a bug so it will verify correctly only if you enter
   numbers in this field for example “12.1”, “-5”.

Viewing 1 replies (of 1 total)

The topic ‘Custom Field Types’ is closed to new replies.

 * ![](https://ps.w.org/wpadverts/assets/icon-256x256.png?rev=2423472)
 * [WPAdverts - Classifieds Plugin](https://wordpress.org/plugins/wpadverts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpadverts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpadverts/)
 * [Active Topics](https://wordpress.org/support/plugin/wpadverts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpadverts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpadverts/reviews/)

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [format](https://wordpress.org/support/topic-tag/format/)

 * 1 reply
 * 2 participants
 * Last reply from: [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/custom-field-types/#post-6833129)
 * Status: resolved