Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Hi, I'm trying to validate a user input to trigger off an image to appear when characters are input into textfield

For example, when a Visa or american express number is input into a textfield to make a purchase, the icon will appear according to the numbers input. I understand it would require an if statement but I'm not entirely sure how to return an image to appear. Thanks.

1 Answer

Steven Parker
Steven Parker
243,656 Points

An easy way to do this is to use CSS to make the image not visible to begin with, and then when the conditions are met, change the CSS to allow the image to be seen.

Examples of doing things like this will be found in some of the basic courses.