473,651 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

indexOf does not work?

Hi All,

I have this code. When I type in je***@ebay.com, it should run
alert("Thanks for your interest.") line. But it does not. Why and
how can I correct it? I use IE 6 with windows xp.
Thanks a lot.

<HTML><body>
<form name="myForm">
<INPUT TYPE="text" VALUE="Enter email" NAME="userEmail "
onChange=valida teInput()>
</form>
<script type="text/javascript">
this.myForm.use rEmail.select()
function validateInput() {
userInput = this.myForm.use rEmail.value
document.write( userInput)
if (userInput.inde xOf('@')>0 && userInput.index Of('.')>0)
alert("Thanks for your interest.")
else
alert("Please check that your email details are correct before
submitting")
}
</script>
Jul 23 '05 #1
13 1971
On 25 Sep 2004 22:25:02 -0700, in comp.lang.javas cript
je************@ hotmail.com (Jenny) wrote:
| Hi All,
|
| I have this code. When I type in je***@ebay.com, it should run
| alert("Thanks for your interest.") line. But it does not. Why and
| how can I correct it? I use IE 6 with windows xp.
| Thanks a lot.
|
| <HTML><body>
| <form name="myForm">
| <INPUT TYPE="text" VALUE="Enter email" NAME="userEmail "
| onChange=valida teInput()>
| </form>
| <script type="text/javascript">
| this.myForm.use rEmail.select()
| function validateInput() {
| userInput = this.myForm.use rEmail.value
| document.write( userInput)
Replace the above line with alert( userInput );
| if (userInput.inde xOf('@')>0 && userInput.index Of('.')>0)
| alert("Thanks for your interest.")
| else
| alert("Please check that your email details are correct before
| submitting")
| }
| </script>


---------------------------------------------------------------
jn****@yourpant sbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 23 '05 #2
Lee
Jenny said:

Hi All,

I have this code. When I type in je***@ebay.com, it should run
alert("Thank s for your interest.") line. But it does not. Why and
how can I correct it? I use IE 6 with windows xp.
Thanks a lot.

<HTML><body>
<form name="myForm">
<INPUT TYPE="text" VALUE="Enter email" NAME="userEmail "
onChange=valid ateInput()>
</form>
<script type="text/javascript">
this.myForm.us erEmail.select( )
function validateInput() {
userInput = this.myForm.use rEmail.value
document.write (userInput)


At this point, you've re-opened the current document and
written new HTML into it. Any previously existing HTML
or Javascript code in this page has been destroyed.
Any code that expects to interact with the previous HTML
or Javascript will fail.

Jul 23 '05 #3
In article <88************ *************@p osting.google.c om>,
je************@ hotmail.com (Jenny) wrote:
if (userInput.inde xOf('@')>0 && userInput.index Of('.')>0)


There are more complete tests to verify an email address if you are
interested.

See:
http://www.webreference.com/js/tips/990928.html

Robert
Jul 23 '05 #4
On Sun, 26 Sep 2004 17:16:19 GMT, Robert <rc*******@my-deja.com>
wrote:
In article <88************ *************@p osting.google.c om>,
je************@ hotmail.com (Jenny) wrote:
if (userInput.inde xOf('@')>0 && userInput.index Of('.')>0)


There are more complete tests to verify an email address if you are
interested.

See:
http://www.webreference.com/js/tips/990928.html


But please don't use that one, as it rejects completely valid email
addresses.

Jim.
Jul 23 '05 #5
JRS: In article <rc************ *************** **@news1.west.e arthlink.n
et>, dated Sun, 26 Sep 2004 17:16:19, seen in news:comp.lang. javascript,
Robert <rc*******@my-deja.com> posted :
In article <88************ *************@p osting.google.c om>,
je************@ hotmail.com (Jenny) wrote:
if (userInput.inde xOf('@')>0 && userInput.index Of('.')>0)


There are more complete tests to verify an email address if you are
interested.

See:
http://www.webreference.com/js/tips/990928.html


It is *not* possible to verify an e-mail address -
<URL:http://www.merlyn.demo n.co.uk/js-valid.htm#VEmA> ;
indeed , thanks for the reminder, I have just changed the set of
addresses valid here, while not connected to the Internet.

One can only check that the format is compliant with the RFCs, which is
enough, in general, enough to show that an E-address has been attempted.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #6
Jim Ley wrote:
On Sun, 26 Sep 2004 17:16:19 GMT, Robert <rc*******@my-deja.com>
wrote:
In article <88************ *************@p osting.google.c om>,
je************@ hotmail.com (Jenny) wrote:
if (userInput.inde xOf('@')>0 && userInput.index Of('.')>0)


There are more complete tests to verify an email address if you are
interested.

See:
http://www.webreference.com/js/tips/990928.html


But please don't use that one, as it rejects completely valid email
addresses.


And allows invalid E-mail addresses. Her test says: " .@" is a valid
E-mail address.

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq

Jul 23 '05 #7
ji*@jibbering.c om (Jim Ley) wrote in message news:<41******* *******@news.in dividual.net>.. .
http://www.webreference.com/js/tips/990928.html

But please don't use that one, as it rejects completely valid email
addresses.


Does someone have one to recommend?

I am looking for one that will exclude invalid characters too. Might
as well get as in as much validation as possible.

Robert
Jul 23 '05 #8
On 28 Sep 2004 19:54:45 -0700, rc*******@my-deja.com (Robert) wrote:
ji*@jibbering. com (Jim Ley) wrote in message news:<41******* *******@news.in dividual.net>.. .
http://www.webreference.com/js/tips/990928.html

But please don't use that one, as it rejects completely valid email
addresses.


Does someone have one to recommend?


No, it's not worth the effort, the risk of losing a sale because you
reject a valid email address you don't understand isn't worth the
effort.

The cost of having lots of mi****@mouse.co m, or su*****@yourdom ain.com
etc is higher than having an email address - people don't type in
invalid email addresses unless they're also going to type invalid but
syntactically correct if forced to.

Jim.
Jul 23 '05 #9
Jim Ley wrote:
But please don't use that one, as it rejects completely valid email
addresses. Does someone have one to recommend?

No, it's not worth the effort, the risk of losing a sale because you
reject a valid email address you don't understand isn't worth the
effort.


I think this is worrying too much about a situation that will never happen.

If someone goes to a web form to get information or buy a product and enters
an email address with nested comments, etc, then they're just being an ass.
In all my years of seeing forms submitted, I've never (that I can think of)
seen a valid email address from a person genuinely trying to submit the form
that wouldn't pass some simple validation tests.

I have seen my forms without any validation get submitted with values like
me@hotmail.co or me@hotmail.coom etc. Simple javascript validation would
prevent typos like that.
people don't type in
invalid email addresses unless they're also going to type invalid but
syntactically correct if forced to.


This is true. You can't prevent invalid but syntactically correct emails
from being submitted, and you shouldn't even think about trying :)

--
Matt Kruse
http://www.JavascriptToolbox.com
Jul 23 '05 #10

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

Similar topics

3
4061
by: cv | last post by:
Hello All, I have used MultipartRequest like the following to upload images. MultipartRequest multi = new MultipartRequest(request, "../webapps/coreprogram/dealerlogos", 1024 * 1024); It works fine. But When a user accesses through Internet, this does not work.
4
4478
by: Field | last post by:
Hi, the following snippet shows once executed this output: 2 2 I'd have rather expected this output: 2 10
4
7287
by: Reena | last post by:
Hi, code from .aspx page... using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web;
4
2885
by: Das | last post by:
Hi, I have made an application in ASP.net with C#. The application works fine with localhost. I have uploaded the site. I'm using web user controls in the form. but some of the button do not work when they are clicked. One thing that I have found that they are nested user controls. which do not work. I'm unable to understand what is the problem with that. thanks in advance. Das
1
3122
by: Newbie in ChiTown | last post by:
Here's my code: I am using MS Access and I am trying to update a table (InvoiceDetails) with data input by the user on a form. However, it does not update nor does it give me an error message. Code listed below. Also, can you recommend a book on SQL. Thanks. Dim con As Object Dim rs As ADODB.Recordset
11
3381
by: Jim | last post by:
Hi, I want to schedule a Python program that reads the command line for input. However, when adding an argument to the command line Python will not pick it up when using Windows scheduled tasks. How do I get it to work? Thanks, Jim
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8576
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
7296
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
6157
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
5609
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
4143
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
4281
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
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
1
1906
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.