Skip to content

Commit

Permalink
Add Validation form JS
Browse files Browse the repository at this point in the history
Add validation form
  • Loading branch information
lerfast committed Apr 22, 2023
1 parent b961d5b commit ff54e8d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
11 changes: 11 additions & 0 deletions form-validation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const form = document.getElementById('form');
function validateForm(event) {
const emailInput = document.getElementById('mail');
const errorMessage = document.getElementById('error-message');
if (emailInput.value !== emailInput.value.toLowerCase()) {
event.preventDefault();
errorMessage.innerHTML = `Please use only lowercase. try:${emailInput.value.toLowerCase()}`;
}
}

form.addEventListener('submit', validateForm);
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ <h2 class="white">Contact me</h2>
</li>
</ul>
</li>
<div id="error-message"></div>
<li>
<div id="maxText" class="input-div">
<textarea
Expand All @@ -186,6 +187,7 @@ <h2 class="white">Contact me</h2>
</div>
</section>
<script src="scripts.js"></script>
<script src="form-validation.js"></script>
<script src="popup.js"></script>
</body>
</html>

0 comments on commit ff54e8d

Please sign in to comment.