Hi
Following form validatioin code is working fine on IE but not working on Mozilla Firefox V2.
Can any body suggest?
Regards - <script ="JAVASCRIPT" type="text/javascript">
-
//--------------- LOCALIZEABLE GLOBALS ---------------
-
var d=new Date();
-
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
-
//Ensure correct for language. English is "January 1, 2004"
-
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
-
-
//--------------- END LOCALIZEABLE ---------------
-
//-----validation scripts--------- -->
-
-
function validate()
-
{
-
var name=form1.name.value;
-
var email =form1.email.value;
-
var phone=form1.phone.value;
-
-
var mymail = /^[a-zA-Z]\w*@{1}\w+\.[a-z]/;
-
-
if(name=="")
-
{
-
alert('Please enter your Name');
-
form1.name.focus();
-
return false;
-
}
-
else if( phone=='')
-
{
-
alert('Please enter your phone number');
-
form1.phone.focus();
-
return false;
-
}
-
else if(isNaN(phone))
-
{
-
alert('Please enter your phone number properly. \n Avoid space,hyphen or any special character. ');
-
form1.phone.focus();
-
return false;
-
}
-
-
else if(email=="")
-
{
-
alert('Please enter your email address');
-
form1.email.focus();
-
return false;
-
}
-
-
else if(!mymail.test(email))
-
{
-
alert("Please enter your email properly.");
-
form1.email.focus();
-
return false;
-
}
-
-
-
else
-
return true;
-
-
}
-
</script>
-
9 5286
Hello javakid, welcome to The Scripts.
I've tested your code and it works fine in Firefox. Maybe it's your form that is the problem. Post your HTML.
Hello javakid, welcome to The Scripts.
I've tested your code and it works fine in Firefox. Maybe it's your form that is the problem. Post your HTML.
Hi acoder,
Thank you for your reply. Here is the HTML code
[HTML]<form name="form1" method=post id="form1" onsubmit="return validate()" action="feedback_submit.php" >
<table border=0 width=90% cellpadding=5 cellspacing=5>
<tr><td valign=top><strong>Name:</strong></td><td><input type="text" name="name" size="32" /> </td></tr>
<tr><td valign=top><strong>Company Details:</strong></td><td><textarea name="comp_details" rows="5" cols="24"></textarea></td></tr>
<tr><td valign=top><strong>Phone:</strong></td><td><input type="text" name="phone" size="32" /></td></tr>
<tr><td valign=top><strong>Email:</strong></td><td><input type="text" name="email" size="32" /></td></tr>
<tr><td valign=top><strong>Technical Specifications or <br> Comments(If any)</strong></td><td><textarea name="spec" rows="5" cols="24"></textarea></td></tr>
<tr><td align=right valign=top><input type="reset" style="background-color:#D5EDB3;"></td><td>
<input type="submit" value="Submit" style="background-color:#D5EDB3;" >
</td></tr>
</table>
</form>[/HTML] Please post using code tags - moderator
Again, the code works fine. What error message are you getting?
Again, the code works fine. What error message are you getting?
Dear
i do not get any error message, thats the main problem!
it do work fine in IE , but validations doesn't work in Firefox. It simply submits the data without validation checking.
If it is works fine on your side then it must be some other issues thats causing problem.
Thanks & regards
Javakid
Dear
i do not get any error message, thats the main problem!
it do work fine in IE , but validations doesn't work in Firefox. It simply submits the data without validation checking.
If it is works fine on your side then it must be some other issues thats causing problem.
Thanks & regards
Javakid
I think you'll find that you are getting an error in the console and quite rightly. You refer to a variable called form1 but it's not defined anywhere.
Mozilla doesn't allow sloppy addressing; try document.forms.form1 .
i do not get any error message, thats the main problem!
If you will be debugging in Firefox a lot I would down load Firebug. It is an extension for Firefox that gives you a ton of info on JavaScript errors being thrown in Firefox. You can Google to find a place to download it.
I would suggest you two things!
first access your form by accessing DOM, not directly by its name.
i.e. var frm = document.forms["form1"];
second is that you should change the name of the name field, as many times if we use predefined attributes name as element names, then it creates problem.
You could rename it as abc_name.
try this, I hope this would help.
I think you'll find that you are getting an error in the console and quite rightly. You refer to a variable called form1 but it's not defined anywhere.
Mozilla doesn't allow sloppy addressing; try document.forms.form1 .
Good spot. Sometimes I don't look and just test the code(!)
Or you could use - document.getElementById('form1')
since you've set the id of the form.
I would suggest you two things!
first access your form by accessing DOM, not directly by its name.
i.e. var frm = document.forms["form1"];
second is that you should change the name of the name field, as many times if we use predefined attributes name as element names, then it creates problem.
You could rename it as abc_name.
try this, I hope this would help.
Yes, good suggestions. The second one is quite important - it's bad practice to use such names and it tends to cause problems in IE ('Object doesn't support this property or action' or something to that effect).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Gregory Piñero |
last post by:
Hi guys,
I'm trying to run this statement:
os.system(r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + '
"www.blendedtechnologies.com"')
The goal is to have firefox open to that website....
|
by: mr_burns |
last post by:
hi,
i am using the following code which works well in internet explorer
but not in firefox (and perhaps others too):
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";...
|
by: Lachlan Hunt |
last post by:
Hi,
I've been looking up lots of documentation and trying to work out a
cross-platform method of capturing a keyboard event and working out
which key was pressed. From what I can find, there...
|
by: ergobob |
last post by:
Hello,
I have two scroll boxes on the same page. The first scroll box is good in IE
but the words will not wrap correctly in Firefox. The second scroll box is
good in all browsers.
You can...
|
by: Atul Chaturvedi |
last post by:
If we use ASP.NET 2.0 Login Control, we are unable to click on Login and
Reset Buttons on Safari running on Apple Mac OS X Version 10.3.2 .
How can i resolve the problem.
|
by: Coder |
last post by:
Hi I have the following code in java script, it is not giving proper
output in FIREFOX but running fine in IE... can anybody help me out to
make this run in FIREFOX .
<script...
|
by: ajaysoniji |
last post by:
Hi,
I am using this code to read the option values from a select option. I am getting the reference of that select option in arg1. Its working fine with mozilla firefox but not with Internet...
|
by: menakasrinivasagam |
last post by:
my coding is working in mozilla firefox.but not working in Internet explorer.plz give suggestion to rectify this problem
|
by: prasad9490024564 |
last post by:
Hi Team,
We are developing crossbrowsing type application with asp.net2.0
In my page i am having server side label control
<asp:Label id="Label1" runat="server" Width="100px" >I am quite a bit...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |