Link to home
Start Free TrialLog in
Avatar of Westside2004
Westside2004Flag for United States of America

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').validateCreditCard(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.
Avatar of bissellGR
bissellGR

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
Avatar of Westside2004
Westside2004
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Westside2004

ASKER

Ended up solving the issue myself.