_comment.php
3 days ago
_db.php
3 days ago
_hidden.php
3 days ago
_label.php
3 days ago
_row.php
3 days ago
attachment.php
3 days ago
checkbox.php
3 days ago
cleditor.php
3 days ago
codemirror.php
3 days ago
color.php
3 days ago
currency.php
3 days ago
date.php
3 days ago
datetime.php
3 days ago
email.php
3 days ago
link.php
3 days ago
number.php
3 days ago
oembed.php
3 days ago
password.php
3 days ago
phone.php
3 days ago
radio.php
3 days ago
select.php
3 days ago
slider.php
3 days ago
slug.php
3 days ago
text.php
3 days ago
textarea.php
3 days ago
time.php
3 days ago
tinymce.php
3 days ago
website.php
3 days ago
number.php
48 lines
| 1 | <?php |
| 2 | // Don't load directly. |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | die( '-1' ); |
| 5 | } |
| 6 | |
| 7 | $field_number = PodsForm::field_loader( 'number' ); |
| 8 | |
| 9 | $value = $field_number->format( $value, $name, $options, $pod, $id ); |
| 10 | |
| 11 | $attributes = array(); |
| 12 | $attributes['type'] = 'text'; |
| 13 | $attributes['value'] = $value; |
| 14 | $attributes['tabindex'] = 2; |
| 15 | $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type, $options ); |
| 16 | |
| 17 | global $wp_locale; |
| 18 | |
| 19 | if ( '9999.99' == pods_var( 'number_format', $options ) ) { |
| 20 | $thousands = ','; |
| 21 | $dot = '.'; |
| 22 | } elseif ( '9999,99' == pods_var( 'number_format', $options ) ) { |
| 23 | $thousands = '.'; |
| 24 | $dot = ','; |
| 25 | } elseif ( '9.999,99' == pods_var( 'number_format', $options ) ) { |
| 26 | $thousands = '.'; |
| 27 | $dot = ','; |
| 28 | } else { |
| 29 | $thousands = $wp_locale->number_format['thousands_sep']; |
| 30 | $dot = $wp_locale->number_format['decimal_point']; |
| 31 | } |
| 32 | $regex_test = '^[0-9\\' . implode( '\\', array_filter( array( $dot, $thousands ) ) ) . '\\-]$'; |
| 33 | $regex_replace = '[^0-9\\' . implode( '\\', array_filter( array( $dot, $thousands ) ) ) . '\\-]'; |
| 34 | ?> |
| 35 | <input<?php PodsForm::attributes( $attributes, $name, $form_field_type, $options ); ?>/> |
| 36 | <script> |
| 37 | jQuery( function ( $ ) { |
| 38 | $( 'input#<?php echo esc_js( $attributes['id'] ); ?>' ).on( 'blur', function () { |
| 39 | if ( !/<?php echo $regex_test; ?>/.test( $( this ).val() ) ) { |
| 40 | var newval = $( this ) |
| 41 | .val() |
| 42 | .replace( /<?php echo $regex_replace; ?>/g, '' ); |
| 43 | $( this ).val( newval ); |
| 44 | } |
| 45 | } ); |
| 46 | } ); |
| 47 | </script> |
| 48 |