I am new to Javascript ... I am making a form in html and validating it through JS ... I recently found code for checking email from web surfing ... I understand the main purpose of the functions used in this code, but I'm not able to understand the logic well ... please, if someone can make me understand the logic of this code easily ... it gets troubling for me a lot ... please step by step in your answer explaining ... code:
if (document.formname.fieldname.value.length >0) {
i=document.formname.fieldname.value.indexOf("@")
j=document.formname.fieldname.value.indexOf(".",i)
k=document.formname.fieldname.value.indexOf(",")
kk=document.formname.fieldname.value.indexOf(" ")
jj=document.formname.fieldname.value.lastIndexOf(".")+1
len=document.formname.fieldname.value.length
if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) {
}
else {
alert("Please enter an exact email address.\n" +
document.formname.fieldname.value + " is invalid.");
return false;
}
}
I will be very grateful to you, people ... I look forward to hearing ... Sincerely !!!
source
share