Westside2004
asked on
Javascript function not executing because input field isn't in the DOM
Hi,
I'm trying to use this credit card validation library (http://jquerycreditcardvalidator.com/) and the primary method you call must have this structure:
$('#card_number').validate CreditCard (function( result) {
});
My form is a javascript multi-step wizard so the "card_number ( <input id="card_number" />) field isn't shown on step 1, it gets shown once the user reaches step 4 so when the page loads the above code doesn't really do anything because the "card_number" field isn't in the DOM I believe. I'm wondering how can I attach the above snippet so when the credit card number field is visible the function will work as expected.
Any help appreciated.
I'm trying to use this credit card validation library (http://jquerycreditcardvalidator.com/) and the primary method you call must have this structure:
$('#card_number').validate
});
My form is a javascript multi-step wizard so the "card_number ( <input id="card_number" />) field isn't shown on step 1, it gets shown once the user reaches step 4 so when the page loads the above code doesn't really do anything because the "card_number" field isn't in the DOM I believe. I'm wondering how can I attach the above snippet so when the credit card number field is visible the function will work as expected.
Any help appreciated.
Can you please provide the HTML on this. If you use a multi-step wizard using JavaScript/jQuery, the form elements would all remain on the page, and the validation wouldn't need to happen until you were ready for it. Without knowing how the page is set up for execution, it makes it tough to help on this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ended up solving the issue myself.