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