Skip to content

Commit

Permalink
Merge pull request #99 from nitinraj-tarento/patch-1
Browse files Browse the repository at this point in the history
email validation for invalid email with regex and blank email field
  • Loading branch information
Haritest authored Jun 15, 2023
2 parents 456b46c + b1ce685 commit 55f4402
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ansible/artifacts/sunbird/login/login.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,13 @@
function validateEmailChar() {
document.getElementById("login").disabled = false
const validRegex = "/^[a-z0-9_-]+(?:\.[a-z0-9_-]+)*@((?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?){2,}\.){1,3}(?:\w){2,}$/"
let userEmail = document.getElementById("username").value
if (userEmail && userEmail.length > 0) {
if(userEmail.length > 5 && !userEmail.match(validRegex)) {
document.getElementById("emailLengthErr").innerHTML = "email is not valid"
document.getElementById("login").disabled = true
}
const email = userEmail.split('@')
if (email && email.length === 2) {
if((email[0] && email[0].length > 64 ) || (email[1] && email[1].length >255)) {
Expand All @@ -309,8 +314,12 @@
}
}
}
else if (userEmail.length == 0) {
document.getElementById("emailLengthErr").innerHTML = "email field can not be blank"
document.getElementById("login").disabled = true
}
}
</script>
</#if>
</#if>
</@layout.registrationLayout>
</@layout.registrationLayout>

0 comments on commit 55f4402

Please sign in to comment.