-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from u-sri2002/submission-success
Submission success
- Loading branch information
Showing
5 changed files
with
116 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,38 @@ | ||
const name = document.getElementById('name'); | ||
const email = document.getElementById('email'); | ||
const form = document.getElementById('form'); | ||
|
||
const name_error = document.getElementById('name_error'); | ||
|
||
const email_error = document.getElementById('email_error'); | ||
|
||
|
||
|
||
form.addEventListener('submit',(e)=> | ||
{ | ||
|
||
|
||
{ | ||
//email regx | ||
var email_check = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; | ||
|
||
|
||
|
||
if(name.value === '' || name.value == null) | ||
|
||
{ | ||
{// prevent default submission | ||
e.preventDefault(); | ||
name_error.innerHTML = "Name is required"; | ||
name_error.innerHTML = "Name is required"; // send error for name | ||
} | ||
|
||
|
||
else | ||
{ | ||
name_error.innerHTML = ""; | ||
} | ||
|
||
|
||
|
||
if(!email.value.match(email_check)) | ||
{ | ||
e.preventDefault(); | ||
email_error.innerHTML = "Valid Email is required"; | ||
email_error.innerHTML = "Valid Email is required"; // send error for email | ||
|
||
} | ||
|
||
|
||
else | ||
{ | ||
email_error.innerHTML = ""; | ||
email_error.innerHTML = ""; | ||
} | ||
// when submission is a success | ||
alert("Submission is Success"); | ||
|
||
|
||
}) | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters