M
Mike
I'm using a script provided by e-mailanywhere, it's a little too big
for me.
There's 1 text field and 1 password field in a form.
OnSubmit, I would like both fields to be validated to look for invalid
digits (~`!#$%^&*()+=?/). This is not working yet, I don't know why.
In addition, I would like both fields to require from 1 to 12 digits
for submition to continue.
The text field also Lowers Case, can you tell me how to do the same on
password field?
I would like to ask that if you reply, please write exactly how you
would modify the script, it's of a lot more help. Thanks in advance
for all replies, below is the page I have:
<html>
<head>
<title>Chech Your Email</title>
<script language="JavaScript">
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
function trimspace(str)
{
temp_str = "";
for (i=0; i<str.length; i++) {
c = str.charAt(i);
if (c != " "){
temp_str = str.substring(i, str.length);
break;
}
}
for (i=temp_str.length-1; i>=0; i--) {
c = temp_str.charAt(i);
if (c != " ") {
temp_str = temp_str.substring(0, i+1);
break;
}
}
return temp_str;
}
function validate_str(str) {
var ok = 1;
if (str.indexOf("~") != -1)
ok = 0;
if (str.indexOf("`") != -1)
ok = 0;
if (str.indexOf("!") != -1)
ok = 0;
if (str.indexOf("#") != -1)
ok = 0;
if (str.indexOf('$') != -1)
ok = 0;
if (str.indexOf("%") != -1)
ok = 0;
if (str.indexOf("^") != -1)
ok = 0;
if (str.indexOf("&") != -1)
ok = 0;
if (str.indexOf("*") != -1)
ok = 0;
if (str.indexOf("(") != -1)
ok = 0;
if (str.indexOf(")") != -1)
ok = 0;
if (str.indexOf("+") != -1)
ok = 0;
if (str.indexOf("=") != -1)
ok = 0;
if (str.indexOf("?") != -1)
ok = 0;
if (str.indexOf("/") != -1)
ok = 0;
if (ok == 0) {
alert("Invalid input - cannot contain ~ ` ! # $ % ^ & * ( ) + = ?
/");
return -1;
} else
return 1;
}
function update(theform) {
var email = trimspace(document.forms[theform].emailaddress.value);
if (email == "") {
alert("Please Enter Your User Name.");
return;
}
if (email.indexOf("@") == -1) {
email = email + "@somepage.com"
}
else if (email.indexOf(".") == -1) {
alert("Please Enter a Valid Email Address.");
return;
}
document.forms[theform].emailaddress.value = email;
document.forms[theform].submit();
}
function lemmein(keypressed){
var key;
if (document.all) {
key=window.event.keyCode;
} else {
key=keypressed.which;
};
if (key==13) {
update("email");
}
}
function handleEnter (field, event) {
var keyCode = event.keyCode ? event.keyCode : event.which ?
event.which : event.charCode;
if (keyCode == 13) {
var i;
for (i = 0; i < field.form.elements.length; i++)
if (field == field.form.elements)
break;
i = (i + 1) % field.form.elements.length;
field.form.elements.focus();
return false;
}
else
return true;
}
// -->
</script>
</head>
<body>
<form name="email" method="POST"
action="http://www.e-mailanywhere.com/servlet/emailLogin">
<input type="hidden" name="logoutURL" value="http://www.somepage.com">
<input type="text" name="emailaddress" size="20" value=""
onkeypress="return handleEnter(this, event)"
onChange="javascript:this.value=this.value.toLowerCase();">
<input type="password" name="password" onkeypress="return
handleEnter(this, event)" size="19" onBlur="">
<input type="button" onClick='javascript:update("email");' value="Log
In">
<br>Powered by <a title="e-mailanywhere.com"
href="http://www.e-mailanywhere.com">e-mailanywhere</a>.
</form>
</body>
</html>
for me.
There's 1 text field and 1 password field in a form.
OnSubmit, I would like both fields to be validated to look for invalid
digits (~`!#$%^&*()+=?/). This is not working yet, I don't know why.
In addition, I would like both fields to require from 1 to 12 digits
for submition to continue.
The text field also Lowers Case, can you tell me how to do the same on
password field?
I would like to ask that if you reply, please write exactly how you
would modify the script, it's of a lot more help. Thanks in advance
for all replies, below is the page I have:
<html>
<head>
<title>Chech Your Email</title>
<script language="JavaScript">
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
function trimspace(str)
{
temp_str = "";
for (i=0; i<str.length; i++) {
c = str.charAt(i);
if (c != " "){
temp_str = str.substring(i, str.length);
break;
}
}
for (i=temp_str.length-1; i>=0; i--) {
c = temp_str.charAt(i);
if (c != " ") {
temp_str = temp_str.substring(0, i+1);
break;
}
}
return temp_str;
}
function validate_str(str) {
var ok = 1;
if (str.indexOf("~") != -1)
ok = 0;
if (str.indexOf("`") != -1)
ok = 0;
if (str.indexOf("!") != -1)
ok = 0;
if (str.indexOf("#") != -1)
ok = 0;
if (str.indexOf('$') != -1)
ok = 0;
if (str.indexOf("%") != -1)
ok = 0;
if (str.indexOf("^") != -1)
ok = 0;
if (str.indexOf("&") != -1)
ok = 0;
if (str.indexOf("*") != -1)
ok = 0;
if (str.indexOf("(") != -1)
ok = 0;
if (str.indexOf(")") != -1)
ok = 0;
if (str.indexOf("+") != -1)
ok = 0;
if (str.indexOf("=") != -1)
ok = 0;
if (str.indexOf("?") != -1)
ok = 0;
if (str.indexOf("/") != -1)
ok = 0;
if (ok == 0) {
alert("Invalid input - cannot contain ~ ` ! # $ % ^ & * ( ) + = ?
/");
return -1;
} else
return 1;
}
function update(theform) {
var email = trimspace(document.forms[theform].emailaddress.value);
if (email == "") {
alert("Please Enter Your User Name.");
return;
}
if (email.indexOf("@") == -1) {
email = email + "@somepage.com"
}
else if (email.indexOf(".") == -1) {
alert("Please Enter a Valid Email Address.");
return;
}
document.forms[theform].emailaddress.value = email;
document.forms[theform].submit();
}
function lemmein(keypressed){
var key;
if (document.all) {
key=window.event.keyCode;
} else {
key=keypressed.which;
};
if (key==13) {
update("email");
}
}
function handleEnter (field, event) {
var keyCode = event.keyCode ? event.keyCode : event.which ?
event.which : event.charCode;
if (keyCode == 13) {
var i;
for (i = 0; i < field.form.elements.length; i++)
if (field == field.form.elements)
break;
i = (i + 1) % field.form.elements.length;
field.form.elements.focus();
return false;
}
else
return true;
}
// -->
</script>
</head>
<body>
<form name="email" method="POST"
action="http://www.e-mailanywhere.com/servlet/emailLogin">
<input type="hidden" name="logoutURL" value="http://www.somepage.com">
<input type="text" name="emailaddress" size="20" value=""
onkeypress="return handleEnter(this, event)"
onChange="javascript:this.value=this.value.toLowerCase();">
<input type="password" name="password" onkeypress="return
handleEnter(this, event)" size="19" onBlur="">
<input type="button" onClick='javascript:update("email");' value="Log
In">
<br>Powered by <a title="e-mailanywhere.com"
href="http://www.e-mailanywhere.com">e-mailanywhere</a>.
</form>
</body>
</html>