You're building a form validation script in JavaScript. How would you ensure that an email input field contains a valid email address before submitting the form?
- Using Regular Expressions: /^[^s@]+@[^s@]+.[^s@]+$/
- Checking for '@' and '.' occurrences
- Using a predefined list of valid email addresses
- Using validateEmail() function
To ensure that an email input field contains a valid email address in JavaScript, you can use regular expressions. The provided regex (/^[^s@]+@[^s@]+.[^s@]+$/) validates the basic structure of an email address. The correct option offers a robust and standard approach.
Loading...
Related Quiz
- The HTML5
- In TDD, what is typically written before the actual code implementation?
- The <<<<<<<, =======, and >>>>>>> markers in a file indicate the conflicted sections during a merge _______.
- What is ACID in the context of database transactions?
- In database systems, a _______ is a mechanism to control access to data items by multiple transactions.