Add decimal error and fix for refund amount
This commit is contained in:
parent
e6b74ad629
commit
d37f191833
|
@ -109,6 +109,47 @@ jQuery( function ( $ ) {
|
|||
}
|
||||
})
|
||||
|
||||
.on( 'change', '.wc-order-totals #refund_amount[type=text]', function() {
|
||||
var regex;
|
||||
|
||||
if ( $( this ).is( '#refund_amount' ) ) {
|
||||
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
|
||||
} else {
|
||||
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
|
||||
}
|
||||
|
||||
var value = $( this ).val();
|
||||
var newvalue = value.replace( regex, '' );
|
||||
|
||||
if ( value !== newvalue ) {
|
||||
$( this ).val( newvalue );
|
||||
}
|
||||
})
|
||||
|
||||
.on( 'keyup', '.wc-order-totals #refund_amount[type=text]', function() {
|
||||
var regex, error;
|
||||
|
||||
if ( $( this ).is( '#refund_amount' ) ) {
|
||||
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
|
||||
error = 'i18n_mon_decimal_error';
|
||||
} else if ( $( this ).is( '.wc_input_country_iso' ) ) {
|
||||
regex = new RegExp( '([^A-Z])+|(.){3,}', 'im' );
|
||||
error = 'i18n_country_iso_error';
|
||||
} else {
|
||||
regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
|
||||
error = 'i18n_decimal_error';
|
||||
}
|
||||
|
||||
var value = $( this ).val();
|
||||
var newvalue = value.replace( regex, '' );
|
||||
|
||||
if ( value !== newvalue ) {
|
||||
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $( this ), error ] );
|
||||
} else {
|
||||
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $( this ), error ] );
|
||||
}
|
||||
})
|
||||
|
||||
.on( 'init_tooltips', function() {
|
||||
var tiptip_args = {
|
||||
'attribute': 'data-tip',
|
||||
|
|
Loading…
Reference in New Issue