473,395 Members | 2,796 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,395 software developers and data experts.

Form validation doesn't work in Netscape 7.1

Hi,

I am new to this Forum. Thanks in advance for any kind help.

In the following HTML code, when I change the value of one text field
then click "Modify" button, if the validation fails a message will
popup and the cotent of the form should NOT be submitted. (The actual
code connects to the database at the backend so I can check if the
value is submmited).

It works well in IE6.0 and Netscape 4.75.

But in Netscape 7.1, if the validation fails, the message pop up but
the form submit still go through. In another word, the return from JS
function inRangeInteger(), which is triggered by onChange event of the
text field, is ignored when the form submit.

Anything special in Netscape 7.1 for handling Javascript?

Any response is highly appriciated.

**************************************
function inRangeInteger(myField, minValue, maxValue)
{
var iValue;
var message;

iValue = parseInt(myField.value);
if ( (iValue >= parseInt(minValue)) && (iValue <= parseInt(maxValue))
)
{
return (true);
}
else
{
message = "You have entered an invalid value. Please re-enter an
integer value";
}

alert(message);
myField.focus();
return (false);

}
<FORM NAME="pbscConfig" METHOD="POST">

<input type="TEXT" name="text1" onChange="inRangeInteger(this, '1',
'60')">

<input type="TEXT" name="text2" onChange="inRangeInteger(this, '1',
'23')">
....

<input TYPE="SUBMIT" NAME="modifyPbsc" VALUE="MODIFY" >

</FORM>

*********************************************
Jul 23 '05 #1
2 1621
In article <ac**************************@posting.google.com >, menglei00
@hotmail.com enlightened us with...
It works well in IE6.0 and Netscape 4.75.


Then it's correcting a problem. ;)

<FORM NAME="pbscConfig" METHOD="POST">


<form name="someName" method="post" onSubmit="return myValidator(myargs)">

That's the only *reliable* way of stopping form submission when you have a
submit (type=submit) button. Assuming the user has JS, of course.

If you must check the values onChange of the text, fine, but don't rely on
that to stop form submission. Have your myValidator function call the same
code before submission (don't bother with return values in the onChange
unless you want to clear the text (in some UAs), but from your code, you were
throwing them away anyway).

--
--
~kaeli~
Well, aren't we just a flipping ray of sunshine?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
On 19 Aug 2004 13:24:12 -0700, lmeng <me*******@hotmail.com> wrote:
I am new to this Forum. Thanks in advance for any kind help.
Welcome.
In the following HTML code, when I change the value of one text field
then click "Modify" button, if the validation fails a message will
popup and the cotent of the form should NOT be submitted. (The actual
code connects to the database at the backend so I can check if the
value is submmited).

It works well in IE6.0 and Netscape 4.75.

But in Netscape 7.1, if the validation fails, the message pop up but
the form submit still go through. In another word, the return from JS
function inRangeInteger(), which is triggered by onChange event of the
text field, is ignored when the form submit.
Returning false from an onchange handler will do nothing, even if you do
it correctly (which you haven't). :)

To return a value properly, there should be a return statement in the
intrinsic event, too. For example,

<a ... onclick="return myHandler()">

function myHandler() {
return false; // Cancel the click
// or
return true; // Allow the click
}

An change event won't affect a submission anyway. Only two things will:
the form's submit event, and the submit button's click event. The former
is preferred.

<form ... onsubmit="return validate(this)">

function validate(form) {
/* Validate the form using the reference in 'form'.
*
* Returning false from this function will cancel
* the submission.
*/
}

Use the change event to validate a value on the control. Use the submit
event to validate the form as a whole before submission.
Anything special in Netscape 7.1 for handling Javascript?
No. The fact that it had an effect on *any* browser is a surprise.
function inRangeInteger(myField, minValue, maxValue)
{
var iValue;
var message;

iValue = parseInt(myField.value);
The parseInt() function should be called with the radix (base) specified.
Problems can occur otherwise. However, you should check that the value is
actually a valid number first, preferably with a regular expression. For
an integer, you can use:

if(/^([1-9]\d*)|0$/.test(myField.value)) {
// myField contains a valid integer
// that contains no leading zeros.
}

Once you've established that the string represents a number, it's quicker
to use unary plus (+) to perform the conversion:

iValue = +myField.value;
if ( (iValue >= parseInt(minValue)) && (iValue <= parseInt(maxValue))
I'll mention this below.

[snip]
<FORM NAME="pbscConfig" METHOD="POST">
Valid HTML requires that FORM elements have an action attribute. You can't
submit a form otherwise.
<input type="TEXT" name="text1" onChange="inRangeInteger(this, '1',
'60')">

<input type="TEXT" name="text2" onChange="inRangeInteger(this, '1',
'23')">


Rather than passing strings (I'm referring to the second and third
arguments) and converting them to numbers, why don't you pass numbers?

<input ... onchange="inRangeInteger(this, 1, 60);">

Hope that helps,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3

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

Similar topics

21
by: AnnMarie | last post by:
<script language="JavaScript" type="text/javascript"> <!-- function validate(theForm) { var validity = true; // assume valid if(frmComments.name.value=='' && validity == true) { alert('Your...
7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
6
by: Drew | last post by:
I've already created a simple method of ensuring that all form feilds are filled out before the form is submitted to an ASP page for records to be added to the data base. (Sorry about the...
5
by: raagz | last post by:
Hi, I am using the .NET validation controls for validating . The validation works fine with IE but none of them work with Netscape 6 browser. Do i have to configure something in vS.NET to...
2
by: TIBM | last post by:
Hi. I've posted this question on another newsgroup, but I haven't received any answers.. I have a login page where users input userID and password and click a Login button. Before calling the ...
6
by: Stephen | last post by:
Hi, Does Validation controls like "Required field validator".... ever work with Netscape or we have to write javascript for either client-side or write server side validation. Please advice....
4
by: Stephen | last post by:
Hi scott, thanks for the reply but the required field validator does not work "as required" in netscape. suppose i have a text box and a required field validator, when I hit the "button" in IE,...
45
by: Pat | last post by:
its seems asp.net validation doesn't fire when using FireFox? Tested a page and it doesn't fire. It seems the javascript doesn't fire Any ideas?
27
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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,...
0
jinu1996
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...
0
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...
0
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...

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.