473,748 Members | 9,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(myFiel d.value);
if ( (iValue >= parseInt(minVal ue)) && (iValue <= parseInt(maxVal ue))
)
{
return (true);
}
else
{
message = "You have entered an invalid value. Please re-enter an
integer value";
}

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

}
<FORM NAME="pbscConfi g" METHOD="POST">

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

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

<input TYPE="SUBMIT" NAME="modifyPbs c" VALUE="MODIFY" >

</FORM>

*************** *************** ***************
Jul 23 '05 #1
2 1657
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="pbscConfi g" METHOD="POST">


<form name="someName" method="post" onSubmit="retur n myValidator(mya rgs)">

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*******@hotm ail.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="retur n 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(myFiel d.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.v alue)) {
// 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(minVal ue)) && (iValue <= parseInt(maxVal ue))
I'll mention this below.

[snip]
<FORM NAME="pbscConfi g" 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="inRan geInteger(this, '1',
'60')">

<input type="TEXT" name="text2" onChange="inRan geInteger(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="inRan geInteger(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
6252
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 full name is required. Please enter your full name!'); validity = false; frmComments.name.focus();
7
4892
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 because then it didn't work in IE. How can I enable this javascipt form validation to work in Netscape? When I use netscape, none of the alert boxes appear. It submits the form without validating anything.
6
1936
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 formating, my newsreader may make it a mess!) <script language="javascript"> <!-- function Check(form) {
5
304
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 make the validations work in Netscape too or is it .net validation controls dont work with Netscape.
2
1370
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 login functions, I have to check the user ID and the password for invalid data. It works well in IExplorer, but it doesn't show the validation summary (displayed in a Javascript alert box) in Netscape. This is what I have in the asp page: ...
6
2282
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. Stephen
4
438
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, the required field validator captures it and only when I enter some value, it uses "Response.redirect to another page" but in Netscape, it just redirects when I hit the button.
45
4747
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
4752
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 appears that the data goes straight to the processing page, rather than the javascript seeing if data is missing and popping up an alert. I thought it may be because much of the form is populated with data from the db (lists, etc.), but when I leave...
0
9548
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
9374
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9249
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
8244
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...
0
6076
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
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
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
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.