Hello guys,
I have the following piece of code:
function validate()
{
var f = document.form1;
if (f.name.value == "" || f.name.value == '' || f.name.value.length
== 0)
{
alert('Please enter your name');
return false;
}
return true;
}
It works fine in Firefox, and when I use firebug to inspect the code I
don't get any errors. However, it doesn't work for IE. Any reasons
for that, and how can I fix this problem? Thanks. 8 1548
SJ Carter <sj*******@gmail.comwrites:
Hello guys,
I have the following piece of code:
function validate()
{
var f = document.form1;
if (f.name.value == "" || f.name.value == '' || f.name.value.length
== 0)
{
alert('Please enter your name');
return false;
}
return true;
}
It works fine in Firefox, and when I use firebug to inspect the code I
don't get any errors. However, it doesn't work for IE. Any reasons
for that, and how can I fix this problem? Thanks.
You probably really shouldn't have a form element named "name".
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Joost Diepenmaat <jo***@zeekat.nlwrites:
You probably really shouldn't have a form element named "name".
or if you do, you can probably use form.elements.name.value instead of
form.name.value
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
On May 14, 3:30 pm, Joost Diepenmaat <jo...@zeekat.nlwrote:
Joost Diepenmaat <jo...@zeekat.nlwrites:
You probably really shouldn't have a form element named "name".
or if you do, you can probably use form.elements.name.value instead of
form.name.value
--
Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/
Thanks Joost, but it still isn't working. I tried changing the form
element name with no success, and then tried using the
"form.elements....", with identical results.
SJ Carter <sj*******@gmail.comwrites:
On May 14, 3:30 pm, Joost Diepenmaat <jo...@zeekat.nlwrote:
>Joost Diepenmaat <jo...@zeekat.nlwrites:
You probably really shouldn't have a form element named "name".
or if you do, you can probably use form.elements.name.value instead of form.name.value
Thanks Joost, but it still isn't working. I tried changing the form
element name with no success, and then tried using the
"form.elements....", with identical results.
it'd probably help if you post a link to the complete page.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
SJ Carter wrote:
On May 14, 3:30 pm, Joost Diepenmaat <jo...@zeekat.nlwrote:
>Joost Diepenmaat <jo...@zeekat.nlwrites:
>>You probably really shouldn't have a form element named "name".
or if you do, you can probably use form.elements.name.value instead of form.name.value
Thanks Joost, but it still isn't working.
Post the error message, then.
I tried changing the form element name with no success, and then tried
using the "form.elements....", with identical results.
DOM terms collide with markup terms here. Just to clarify, you should not
have a form *control* named "name", i.e. you should not have
<input name="name" ...>
because the form *element*
<form ... name="foo">
...
</form>
would then cause formRef.name to be evaluated to "foo" instead of the input
object. Modifying or removing the `name' attribute value of the `form'
element would not change that, which could explain what you observed.
You have to change the value of the `name' attribute of the `input' element
instead. BTW, "submit" is another name that should be avoided, as form
objects have a submit() method.
Please trim your quotes.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
On May 14, 4:00 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
SJ Carter wrote:
On May 14, 3:30 pm, Joost Diepenmaat <jo...@zeekat.nlwrote:
Joost Diepenmaat <jo...@zeekat.nlwrites: You probably really shouldn't have a form element named "name".
or if you do, you can probably use form.elements.name.value instead of
form.name.value
Thanks Joost, but it still isn't working.
Post the error message, then.
I tried changing the form element name with no success, and then tried
using the "form.elements....", with identical results.
DOM terms collide with markup terms here. Just to clarify, you should not
have a form *control* named "name", i.e. you should not have
<input name="name" ...>
because the form *element*
<form ... name="foo">
...
</form>
would then cause formRef.name to be evaluated to "foo" instead of the input
object. Modifying or removing the `name' attribute value of the `form'
element would not change that, which could explain what you observed.
You have to change the value of the `name' attribute of the `input' element
instead. BTW, "submit" is another name that should be avoided, as form
objects have a submit() method.
Please trim your quotes.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Got it working. Turns out it wasn't even that function itself, but
some embedded object that was messing things up. Thanks for all your
help!
SJ Carter a écrit :
On May 14, 3:30 pm, Joost Diepenmaat <jo...@zeekat.nlwrote:
>Joost Diepenmaat <jo...@zeekat.nlwrites:
>>You probably really shouldn't have a form element named "name".
or if you do, you can probably use form.elements.name.value instead of form.name.value
Thanks Joost, but it still isn't working. I tried changing the form
element name with no success, and then tried using the
"form.elements....", with identical results.
Give another name than 'name' to your element would fix the trouble.
but the right use to get an element named 'name' and from the form named
'form1' is :
document.forms['form1'].elements['name']
or :
document.form1['name']
It is aways a good idea to do not use generic terms to name something
(here 'name' is an attribute and IE can misunderstand of what name you talk)
--
sm
On 14 mai, 18:36, SJ Carter <sjmcar...@gmail.comwrote:
Thanks Joost, but it still isn't working. I tried changing the form
element name with no success, and then tried using the
"form.elements....", with identical results.
Using Web Standards in your Web Pages
Accessing Elements with the W3C DOM http://developer.mozilla.org/en/docs...th_the_W3C_DOM
will for sure give you the help you are seeking.
Gérard This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave Blair |
last post by:
Hi,
I have a problem with our intranet, we are planning to install Firefox
instead of Internet Explorer onto some new PCs.
However, we can't get the following JavaScript to work in Firefox and...
|
by: Ryan Ternier |
last post by:
We're running a site that has required field validation on the login page.
It works fine on our development / test machines. However, when I upload
this site to our live server i get this error.
...
|
by: Andre |
last post by:
Hi,
I have read at many place that .Net 2.0 was suppose to support
client-side validation in non-IE Browser. But i've try a very simple
validation, and firefox is unable to run it, it works only...
|
by: chrisdude911 |
last post by:
how do i add video into a javascript web page with my own custom
buttons?
|
by: goga |
last post by:
Hi there,
The following simple validation code works in internet explorer but
doesn't in firefox.
Specifically, in firefox shows the alert message and then loads the
action page anyway.
Any...
|
by: Chris |
last post by:
Hi,
I have a form for uploading documents and inserting the data into a mysql
db. I would like to validate the form. I have tried a couple of Javascript
form validation functions, but it...
|
by: davidiwharper |
last post by:
Hi there.
I'm putting together a page to collect some information from our website users and send the administrator an email. To this end I have some Javascript form validation in an external...
|
by: cbs7 |
last post by:
Hi all
I'm a complete newbie to web development and Javascript especially. I've been creating a form for a webpage and have used a validation script gen_validatorv2.js which I downloaded from the...
|
by: goldenv |
last post by:
Hi all,
I have worked an open source javascript + html page that has the
potential to replace your existing browser home page. If you are
interested in trying it out, or learning more about it, it...
|
by: PrabodhanP |
last post by:
I hv following javascript form validation code works in IE but not in Mozilla-Firefox ...please suggest
<script type="text/javascript">
function IsNumeric(strString)
// check for valid...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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,...
| |