473,324 Members | 2,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

reject error

A form input where value = viagra is to be rejected using a javascript,
but it doesn't work at all.

Line 30 and on is where the last attempt to get the code to work is.
http://html-channel.com/pastebin.php?id=2

Anyone able to help me with this?

--
Torbjørn Pettersen
Feb 9 '06 #1
14 1505

Torbjørn Pettersen wrote:
A form input where value = viagra is to be rejected using a javascript,
but it doesn't work at all.

Line 30 and on is where the last attempt to get the code to work is.
http://html-channel.com/pastebin.php?id=2

Anyone able to help me with this? document.MyForm.Name.value.toLowerCase().equals(' viagra')


Is there a reason why you can't simply do the following:

document.forms["MyForm"].elements["Name"].toLowerCase() == "viagra"

Because there is no String method "equals".

Feb 9 '06 #2
web.dev wrote:
document.MyForm.Name.value.toLowerCase().equals('v iagra')


Is there a reason why you can't simply do the following:

document.forms["MyForm"].elements["Name"].toLowerCase() == "viagra"

Because there is no String method "equals".


Didn't work. :-(

--
Torbjørn Pettersen
Feb 9 '06 #3
VK

Torbjørn Pettersen wrote:
web.dev wrote:
document.MyForm.Name.value.toLowerCase().equals('v iagra')


Is there a reason why you can't simply do the following:

document.forms["MyForm"].elements["Name"].toLowerCase() == "viagra"

Because there is no String method "equals".


Didn't work. :-(


There is not method "equals" in JavaScript String object. Use simple
comparison instead as suggested:

// WRONG:
if (document.MyForm.Name.value.toLowerCase().equals(' viagra'))

// RIGHT:
if (document.MyForm.Name.value.toLowerCase() == 'viagra')

Feb 9 '06 #4
Try this:

document.MyForm.Name.value.toLowerCase() == "viagra"

- shiva

Torbjørn Pettersen wrote:
web.dev wrote:
document.MyForm.Name.value.toLowerCase().equals('v iagra')


Is there a reason why you can't simply do the following:

document.forms["MyForm"].elements["Name"].toLowerCase() == "viagra"

Because there is no String method "equals".


Didn't work. :-(

--
Torbjørn Pettersen


Feb 9 '06 #5
VK wrote:
There is not method "equals" in JavaScript String object. Use simple
comparison instead as suggested:

// WRONG:
if (document.MyForm.Name.value.toLowerCase().equals(' viagra'))

// RIGHT:
if (document.MyForm.Name.value.toLowerCase() == 'viagra')


Didn't work. No errors, just accepted viagra as input in the name field.

--
Torbjørn Pettersen
Feb 9 '06 #6
sh*************@gmail.com wrote:
Try this:

document.MyForm.Name.value.toLowerCase() == "viagra"


Didn't work. No errors, just accepted viagra as input in the name field.

--
Torbjørn Pettersen
Feb 9 '06 #7
VK

Torbjørn Pettersen wrote:
VK wrote:
There is not method "equals" in JavaScript String object. Use simple
comparison instead as suggested:

// WRONG:
if (document.MyForm.Name.value.toLowerCase().equals(' viagra'))

// RIGHT:
if (document.MyForm.Name.value.toLowerCase() == 'viagra')


Didn't work. No errors, just accepted viagra as input in the name field.


Because you used assignment (=) instead of comparison (==).

Do not retype the code, just copy'n'paste this line:

if (document.MyForm.Name.value.toLowerCase() == 'viagra') {

instead of your current one on the line 31 at
<http://html-channel.com/pastebin.php?id=2>

Feb 9 '06 #8

Torbjørn Pettersen wrote:
A form input where value = viagra is to be rejected using a javascript,
but it doesn't work at all.

Line 30 and on is where the last attempt to get the code to work is.
http://html-channel.com/pastebin.php?id=2

Anyone able to help me with this?

--
Torbjørn Pettersen
<script type='JavaScript'>


You get no errors because your code is being ignored quite rightly as
an unknown type.

<script type='text/JavaScript'>
--
S.C.

Feb 10 '06 #9
Stephen Chalmers wrote:
<script type='JavaScript'>


You get no errors because your code is being ignored quite rightly as
an unknown type.

<script type='text/JavaScript'>


The rest of the script works fine, and changing as you proposed here
didn't do any good either. Almost starting to think this is not fixable.

--
Torbjørn Pettersen
Feb 10 '06 #10
VK

Torbjørn Pettersen wrote:
Stephen Chalmers wrote:
<script type='JavaScript'>


You get no errors because your code is being ignored quite rightly as
an unknown type.

<script type='text/JavaScript'>


The rest of the script works fine, and changing as you proposed here
didn't do any good either. Almost starting to think this is not fixable.


You still have nothing changed: still non-existing equals() method,
still non-existing text/JavaScript content type. Please post or link
the *current last modified* variant you are having problems with.

Please remove all ASP tags as irrelevant: it is indeed difficult to
sort out. The simpliest way is to open your page in the browser, View >
Page Source, copy'n'paste.

We are willing to help, but please help us either.

Feb 10 '06 #11
VK wrote:
You still have nothing changed: still non-existing equals() method,
still non-existing text/JavaScript content type. Please post or link
the *current last modified* variant you are having problems with.

Please remove all ASP tags as irrelevant: it is indeed difficult to
sort out. The simpliest way is to open your page in the browser, View
Page Source, copy'n'paste.


We are willing to help, but please help us either.


Sorry, getting a bit frustrated. Have of course changed the code,
will post link to fresh code as I do changes from now on.

http://html-channel.com/pastebin.php?id=5 is the current last mod
the javascript of the page only.

http://html-channel.com/pastebin.php?id=6 is with html/asp included.

As you see there are two javascripts, the first one nothing works in. :-)
Not even if I don't enter any values into the form. :-/

The second is the one that checks for too long words, which works like
a charm. (Starts on line 69)

I'm no js coder myself, and this is just tweaking code done for
me by a friend who is no longer here to help me. I do understand
what the purpose of the code is, and the piece of code that is to
reject viagra as a input is placed there by me. :-)

--
Torbjørn Pettersen
Feb 10 '06 #12

Torbjørn Pettersen wrote:

http://html-channel.com/pastebin.php?id=6 is with html/asp included.

If you are getting no errors it can be only because you have disabled
error reporting in your browser, or it does not pop-up the JS console
on error (Mozilla/Firefox).

if {document.MyForm.Name.value.toLowerCase == "viagra"}


should be:

if (document.MyForm.Name.value.toLowerCase() == "viagra")

There are also some errors in the if-else constructs, which the JS
console will specify.

--
S.C.
--
S.C.

Feb 10 '06 #13
Torbjørn Pettersen wrote:
sh*************@gmail.com wrote:
Try this:

document.MyForm.Name.value.toLowerCase() == "viagra"


Didn't work. No errors, just accepted viagra as input in the name field.


You should not name a form control `name' because that is the name of a
property of HTMLFormElement objects already. Furthermore, standards
compliant syntax is

document.forms['MyForm'].elements['nameOfYourControl'].value.toLowerCase()
== "viagra"

You want to consider

var e = document.forms['MyForm'].elements['nameOfYourControl'];

// matches "viagra" case-insensitive anywhere in the value
... e.value.test(/viagra/i) ...

// or, for a strict case-insensitive match

... e.value.test(/^viagra$/i) ...

See also previous discussions about form validation; they contain
descriptions of more efficient and less error-prone property accesses.
PointedEars
Feb 16 '06 #14
Thomas 'PointedEars' Lahn wrote on 16 feb 2006 in comp.lang.javascript:
document.forms['MyForm'].elements['nameOfYourControl'].value.toLowerCa
se() == "viagra"


In your case, to keep you in your form, is that what you are controlled by?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 16 '06 #15

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

Similar topics

0
by: James R. Saker Jr. | last post by:
Been digging into this one in Python docs and Beazley's Essential Reference but I must be missing something. I need a UDP server for my syslog collector app (preferably threaded for concurrency) to...
1
by: hellostephen | last post by:
Hi. I'm looking for a way reject an xml document with an attribute that has whitespace only. This is not so hard when the attribute is an empty string but the whitespaces has me stumped. BTW...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
2
by: Brian Worth | last post by:
I have a console app that would like to reject a shutdown/restart request unless a certain condition exists. I have written programs with forms in which you can be notified when the form is about...
3
by: dr | last post by:
I created a basic service using VS2005. Add OnPowerEvent method as detailed on MSDN and return false to a PowerBroadcastStatus.QuerySuspend notification. The service also has set...
0
by: Eric Davidson | last post by:
I am try to find a way to get load to reject a record if the data is too large and not just truncate it. eg. c:\temp\fred3.txt ------ a23456789012345678901234567890...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.