|
From: <sv...@de...> - 2005-05-30 17:23:34
|
Author: svera
Date: 2005-05-30 13:23:26 -0400 (Mon, 30 May 2005)
New Revision: 1200
Modified:
humano2/trunk/web/portal/site/js/inputstocheck.js
Log:
* Fix Bug #137
Modified: humano2/trunk/web/portal/site/js/inputstocheck.js
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/web/portal/site/js/inputstocheck.js 2005-05-30 16:12:15=
UTC (rev 1199)
+++ humano2/trunk/web/portal/site/js/inputstocheck.js 2005-05-30 17:23:26=
UTC (rev 1200)
@@ -42,6 +42,15 @@
var checkEmail =3D value
var mailOk =3D true;
=20
+ if (isValidEmail(checkEmail,true) =3D=3D true)
+ {
+ =20
+ }else{
+ alert("You have entered an invalid email address( " + checkEmail=
+ "). Please try again.");
+ mailOk =3D false; =20
+ }
+ =20
+/* =20
if(checkEmail =3D=3D '' || checkEmail =3D=3D null)
{
return true;
@@ -55,7 +64,7 @@
alert("You have entered an invalid email address( " + checkEmail=
+ "). Please try again.");
mailOk =3D false;
}=09
- =20
+ */ =20
return mailOk;
}
=20
@@ -198,4 +207,47 @@
aNewInput.Check() =3D=3D false );
}
=20
+//Mail functions
=20
+function isValidEmail(email, required) {
+ if (required=3D=3Dundefined) { // if not specified, assume it's re=
quired
+ required=3Dtrue;
+ }
+ if (email=3D=3Dnull) {
+ if (required) {
+ return false;
+ }
+ return true;
+ }
+ if (email.length=3D=3D0) { =20
+ if (required) {
+ return false;
+ }
+ return true;
+ }
+ if (! allValidChars(email)) { // check to make sure all characters =
are valid
+ return false;
+ }
+ if (email.indexOf("@") < 1) { // must contain @, and it must not be=
the first character
+ return false;
+ } else if (email.lastIndexOf(".") <=3D email.indexOf("@")) { // las=
t dot must be after the @
+ return false;
+ } else if (email.indexOf("@") =3D=3D email.length) { // @ must not =
be the last character
+ return false;
+ }
+=09
+ return true;
+}
+
+function allValidChars(email) {
+ var parsed =3D true;
+ var validchars =3D "abcdefghijklmnopqrstuvwxyz0123456789@.-";
+ for (var i=3D0; i < email.length; i++) {
+ var letter =3D email.charAt(i).toLowerCase();
+ if (validchars.indexOf(letter) !=3D -1)
+ continue;
+ parsed =3D false;
+ break;
+ }
+ return parsed;
+}
|