sasha85
asked on
email validation
when we want to check if the inserted data is a valid email we need to check if there is a @ inside...
but we also need to check if after the @ comes a word and after it comes a point(.)
and after it may be another word with point...and so on 3 times...
for example
sash85@mailer.ru.ua
i am sure you have done it so many times:)
can you help to match it to my script here:
*my text input name is 'tomail'
but we also need to check if after the @ comes a word and after it comes a point(.)
and after it may be another word with point...and so on 3 times...
for example
sash85@mailer.ru.ua
i am sure you have done it so many times:)
can you help to match it to my script here:
*my text input name is 'tomail'
function validate5(){
if (!validate4()) return false;
if (document.reportgen.tomail.value == "") {
alert(document.getElementById('fillmail').innerHTML);
return false;
}
return true;
};
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if it is invalid, it will through AddressException!
ASKER
javascript:
function validate5(){
if (!validate4()) return false;
if (document.reportgen.tomail .value == "") {
alert(document.getElementB yId('fillm ail').inne rHTML);
return false;
}
return true;
};
can you please show how i combine with
something like this
http://www.devx.com/tips/Tip/28334
but not just hotmail...any mailer...
function validate5(){
if (!validate4()) return false;
if (document.reportgen.tomail
alert(document.getElementB
return false;
}
return true;
};
can you please show how i combine with
something like this
http://www.devx.com/tips/Tip/28334
but not just hotmail...any mailer...
do you want a javascritp fuction?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
wow! this is one long script...i will use it...
the operator comand is "onsubmit" , i cant use it on the in the <form...>
<form name=emailform onSubmit="return emailCheck(this.email.valu e);">
can i somehow operat it from
my submit button:
response.write "<br><a href=""#"" onClick=""if(validate5() ){document.reportgen.actio n='ptomail .asp?rep=1 ';document .reportgen .submit(); }"">submit </a>"
?
the operator comand is "onsubmit" , i cant use it on the in the <form...>
<form name=emailform onSubmit="return emailCheck(this.email.valu
can i somehow operat it from
my submit button:
response.write "<br><a href=""#"" onClick=""if(validate5() ){document.reportgen.actio
?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that part i understand...i asked how i can call this script from my script above or from the submit button
<INPUT TYPE="button" NAME="button" Value="Submit" onClick="your script code goes here">
ASKER
i will explain again:
here is my button:
response.write "<br><a href=""#"" onClick=""if(validate5() ){document.reportgen.actio n='ptomail .asp?rep=1 ';document .reportgen .submit(); }"">submit </a>"
how can i add the operator to that script:
http://javascript.internet.com/forms/check-email.html
into my button
?
here is my button:
response.write "<br><a href=""#"" onClick=""if(validate5() ){document.reportgen.actio
how can i add the operator to that script:
http://javascript.internet.com/forms/check-email.html
into my button
?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
where?
var emailStr = document.reportgen.tomail. value ;
i studied this script a little...there is so much things i can't understand there...
for exmaple why we need this ip check?
var emailStr = document.reportgen.tomail.
i studied this script a little...there is so much things i can't understand there...
for exmaple why we need this ip check?
<SCRIPT LANGUAGE="Javascript">
function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
alert("Email address seems incorrect (check @ and .'s)")
return false
}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
// user is not valid
alert("The username doesn't seem to be valid.")
return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!")
return false
}
}
return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
alert("The domain name doesn't seem to be valid.")
return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
domArr[domArr.length-1].length>3) {
alert("The address must end in a three-letter domain, or two letter country.")
return false
}
if (len<2) {
var errStr="This address is missing a hostname!"
alert(errStr)
return false
}
return true;
}
</script>
ASKER
i thought about it...this script is too much heavy...can you suggest what we can drop?
i just need to check if the structure is email format...
@ word point word (ends with word and not point) and do not use the wrong chars...
i just need to check if the structure is email format...
@ word point word (ends with word and not point) and do not use the wrong chars...