473,770 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help modifying script to validate text field

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="JavaS cript">
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf ("?"))>0&&paren t.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.fo rms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.l ayers&&i<d.laye rs.length;i++)
x=MM_findObj(n, d.layers[i].document);
if(!x && d.getElementByI d) x=d.getElementB yId(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_sw apImage.argumen ts; document.MM_sr= new Array;
for(i=0;i<(a.le ngth-2);i+=3)
if ((x=MM_findObj( a[i]))!=null){docum ent.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgResto re() { //v3.0
var i,x,a=document. MM_sr;
for(i=0;a&&i<a. length&&(x=a[i])&&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.len gth-1; i>=0; i--) {
c = temp_str.charAt (i);
if (c != " ") {
temp_str = temp_str.substr ing(0, i+1);
break;
}
}

return temp_str;
}

function validate_str(st r) {
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(docum ent.forms[theform].emailaddress.v alue);
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.v alue = email;
document.forms[theform].submit();
}

function lemmein(keypres sed){
var key;

if (document.all) {
key=window.even t.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.elem ents.length; i++)
if (field == field.form.elem ents[i])
break;
i = (i + 1) % field.form.elem ents.length;
field.form.elem ents[i].focus();
return false;
}
else
return true;
}

// -->
</script>
</head>
<body>
<form name="email" method="POST"
action="http://www.e-mailanywhere.co m/servlet/emailLogin">
<input type="hidden" name="logoutURL " value="http://www.somepage.co m">
<input type="text" name="emailaddr ess" size="20" value=""
onkeypress="ret urn handleEnter(thi s, event)"
onChange="javas cript:this.valu e=this.value.to LowerCase();">
<input type="password" name="password" onkeypress="ret urn
handleEnter(thi s, event)" size="19" onBlur="">
<input type="button" onClick='javasc ript:update("em ail");' value="Log
In">
<br>Powered by <a title="e-mailanywhere.co m"
href="http://www.e-mailanywhere.co m">e-mailanywhere</a>.
</form>
</body>
</html>
Jul 20 '05 #1
5 4718

"Mike" <ms*****@photos helf.net> schreef in bericht
news:5e******** *************** **@posting.goog le.com...

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:


I did a first-aid rewrite of the scripts, check:

http://www.jwscripts.com/playground/check_email.php

Still needs work, but I think that you will be able to pick it up from here.
JW

Jul 20 '05 #2
"Janwillem Borleffs" <jw@jwscripts.c om> wrote in message news:<3f******* **************@ news.wanadoo.nl >...
"Mike" <ms*****@photos helf.net> schreef in bericht
news:5e******** *************** **@posting.goog le.com...

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:


I did a first-aid rewrite of the scripts, check:

http://www.jwscripts.com/playground/check_email.php

Still needs work, but I think that you will be able to pick it up from here.
JW


Sorry JW, I don't know how to continue, I'm just a beginner. Any more
help is appreciated.
Mike
Jul 20 '05 #3

"Mike" <ms*****@photos helf.net> schreef in bericht
news:5e******** *************** ***@posting.goo gle.com...

Sorry JW, I don't know how to continue, I'm just a beginner. Any more
help is appreciated.


It's more or less useful now, again see:
http://www.jwscripts.com/playground/check_email.php

Be aware that the email address validation is rudimentary, anything that
consists of characters a-z, digits and dots, with an at-sign inbetween is
considered valid.
JW


Jul 20 '05 #4
"Janwillem Borleffs" <jw@jwscripts.c om> writes:
Be aware that the email address validation is rudimentary, anything that
consists of characters a-z, digits and dots, with an at-sign inbetween is
considered valid.


Just a comment because it sounds like you think the e-mail validation
accepts too much. It's probably both too much and too too little.

While it might be problematic to accept foo@bar, it's the false
negatives that are really disasterous, e.g., fo*****@example .com or
"Mr. Foo Bar"@example.co m (both of which are perfectly good e-mail
adresses).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5

"Lasse Reichstein Nielsen" <lr*@hotpop.com > schreef in bericht
news:k7******** **@hotpop.com.. .

Just a comment because it sounds like you think the e-mail validation
accepts too much. It's probably both too much and too too little.


As I said, I consider it rudimentary, which indicates that it's everything
but perfect.
JW

Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
8695
by: Mike | last post by:
I've been trying for the past week to put a simple code together. I have done a LOT of searching, found scripts showing the functions I would like to use, however when I mix them it all goes wrong, somehow I always end up with error messages and functions not working right. Can someone please help me? I have a form, inside is 1 Text Field and 2 Password Fields. What I'm looking to do is: - Make sure password fields are equal - Set...
3
1889
by: Sol Linderstein | last post by:
Hi, I'm writing a CGI application and here's what I'm stuck with. There are some text boxes in an html form that I want to validate. The validation needs to happen on the server side because the data to validate against is inside a mysql database residing on the server. I want to present the user with a popup only if the validation fails. Ideally the user doesn't even know the validation is happening unless it fails. He just moves from...
7
3615
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title> </head> <style type="text/css">
14
2155
by: JNariss | last post by:
Hello, I am fairly new to asp and jscript and am now in the process of learning some form validation. I am taking one step at a time by validating each field and testing it before moving onto the next one to be sure I am correct. I ran into a problem with my validation when I added an else if code to my code. Here is what I tried to do: Form (ITTermination) has a field (EmployeeName) which I would like to validate to check for no...
2
4894
by: this one | last post by:
I have the following code <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" src="..\include\gen_validatorv2.js" type="text/javascript"></script> </head>
6
1910
by: drec | last post by:
I am just learning Javascript and I would like to create a basic form that gives me two options. This will be using either checkbox or radio input type, however I would like the second option to allow the user to type in a value. Also, I would like the 2nd option only editable if the button for that option is selected. All I can seem to find is basic examples of forms, and none of which have this feature. The form would look something...
1
1434
by: Mel | last post by:
I have an entry field and a long number "33424JHKJHKJ43432423" as well as a submit button "FINISHED". I need to know "HOW LONG" it takes for the user to enter the number correctly ! if incorrect, it should popup an alert and ask user to correctly enter the number again and then press FINISHED button Can someone help me a little Codelet ? thanks
36
3110
by: aljamala | last post by:
Hi, I keep getting this warning on a page, but I do not know what the problem is...does anyone have an idea about what could be wrong? line 88 column 7 - Warning: missing </formbefore <td> it highlights this line: <form name="frmCurrency" action="" method="post"> Page source....
0
5576
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10257
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8931
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.