191
rated 0 times
[
195]
[
4]
/ answers: 1 / hits: 54123
/ 10 Years ago, mon, april 28, 2014, 12:00:00
with this piece of jQuery I check if some fields are match or are not empty, but I get this error.
Uncaught TypeError: Cannot read property 'match' of undefined
Can anyone tell me what I am doing wrong here?
if ( width.match( /^d+$/ ) && height.match( /^d+$/ ) && type.length > 0 && color.length > 0 ) {
This is the full code:
if( $( #config ) ) {
$( 'input, select' ).on( 'change', function(){
var width = $( #config-steps #width ).val();
var height = $( #config-steps #height ).val();
var type = $( #config-steps #type ).val();
var color = $( #config-steps #selected-color ).val();
if ( width.match( /^d+$/ ) && height.match( /^d+$/ ) && type.length > 0 && color.length > 0 ) {
$( #checkout-message ).show();
// Change visible price
$( #change-price ).html( calculate_price().toFixed( 2 ) );
} else {
return false;
}
});
}
More From » jquery