LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-03-2006, 07:07 AM   #1
ati
Member
 
Registered: Oct 2005
Location: london
Distribution: fedora 4
Posts: 61

Rep: Reputation: 15
simple form vallidation?


hi all

this basicaly works in opera but not in firefox, i downloaded web developer toolbar extension for firefox and an error came up.

error: form is not defined line 6
if ( form.firsttextbox.value == "" )


here is my html where the form is, can anyone see why opera likes it anf firefox dont any feedback would be great.

thanks for for looking

code:

function validate_form ( )
{
valid = true;


if ( form.firsttextbox.value == "" )
{
alert ( "Please fill in the 'creditcard' box." );
valid = false;
}

if ( form.dow.selectedIndex == 0 )
{
alert ( "Please select your Age." );
valid = false;
}

if ( form.ctime.selectedIndex == 0 )
{
alert ( "Please select your time." );
valid = false;
}

if ( form.cdate.selectedIndex == 0 )
{
alert ( "Please select your date." );
valid = false;
}


return valid;
}



html:
<form id="form" action="second.php" method="get" onsubmit="return validate_form ( );">

thanks
 
Old 05-04-2006, 06:18 AM   #2
redhatrosh
Member
 
Registered: May 2004
Location: Student of University of Mumbai, Maharastra State, India
Distribution: Redhat Linux 9.0, Knoppix LIVE CD, Ubuntu Live CD, Kubuntu Live CD
Posts: 483

Rep: Reputation: 30
Aah..I haven't looked at your code.

But basically, if it tends to work in IE and Opera, it "may" not work in firefox probably, because, Firefox uses a processing engine (code named Gecko) where IE and Opera use Trident and Presto respectively. i AM not sure of this reason, though this might be one of them.

The second thing is you may have another form, so use the collection property to specify, something like
Code:
var x = document.forms[0]
and then use the variable x for the fields. You can use this, even if you have one form on the entire page.

Thirdly, the name "form" might be conflicting!

Hope this helps!

Last edited by redhatrosh; 05-04-2006 at 06:19 AM.
 
Old 05-04-2006, 11:35 AM   #3
ati
Member
 
Registered: Oct 2005
Location: london
Distribution: fedora 4
Posts: 61

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by redhatrosh
Aah..I haven't looked at your code.

But basically, if it tends to work in IE and Opera, it "may" not work in firefox probably, because, Firefox uses a processing engine (code named Gecko) where IE and Opera use Trident and Presto respectively. i AM not sure of this reason, though this might be one of them.

The second thing is you may have another form, so use the collection property to specify, something like
Code:
var x = document.forms[0]
and then use the variable x for the fields. You can use this, even if you have one form on the entire page.

Thirdly, the name "form" might be conflicting!

Hope this helps!

hi

thanks for that it works a treat
 
Old 05-04-2006, 10:20 PM   #4
redhatrosh
Member
 
Registered: May 2004
Location: Student of University of Mumbai, Maharastra State, India
Distribution: Redhat Linux 9.0, Knoppix LIVE CD, Ubuntu Live CD, Kubuntu Live CD
Posts: 483

Rep: Reputation: 30
Quote:
Originally Posted by ati
hi

thanks for that it works a treat
Did it help?..
Do you have successful test results on either browsers?
 
Old 05-05-2006, 02:14 AM   #5
ati
Member
 
Registered: Oct 2005
Location: london
Distribution: fedora 4
Posts: 61

Original Poster
Rep: Reputation: 15
ya it did both browsers

thanks a again
 
Old 05-05-2006, 01:39 PM   #6
redhatrosh
Member
 
Registered: May 2004
Location: Student of University of Mumbai, Maharastra State, India
Distribution: Redhat Linux 9.0, Knoppix LIVE CD, Ubuntu Live CD, Kubuntu Live CD
Posts: 483

Rep: Reputation: 30
Oh, that's good!

Hey, dude, fill up the profile form, and let the community know which distro, are you using... and where are you from!
 
Old 05-05-2006, 01:44 PM   #7
ati
Member
 
Registered: Oct 2005
Location: london
Distribution: fedora 4
Posts: 61

Original Poster
Rep: Reputation: 15
ya no probs
 
Old 05-05-2006, 01:47 PM   #8
ati
Member
 
Registered: Oct 2005
Location: london
Distribution: fedora 4
Posts: 61

Original Poster
Rep: Reputation: 15
where do i fill those details
 
Old 05-06-2006, 10:41 AM   #9
redhatrosh
Member
 
Registered: May 2004
Location: Student of University of Mumbai, Maharastra State, India
Distribution: Redhat Linux 9.0, Knoppix LIVE CD, Ubuntu Live CD, Kubuntu Live CD
Posts: 483

Rep: Reputation: 30
Quote:
Originally Posted by ati
where do i fill those details
If you are logged on, just type http://www.linuxquestions.org and you'll see menu called "MyLQ" and under that, just click on the left hand side navigation link saying "Edit Profile" and fill in details.
 
Old 05-07-2006, 02:23 AM   #10
ati
Member
 
Registered: Oct 2005
Location: london
Distribution: fedora 4
Posts: 61

Original Poster
Rep: Reputation: 15
got it thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple PHP help with a form :-) 2782d4 Programming 3 12-17-2004 02:53 AM
shell script works form command line but not form crontab saifee General 1 10-14-2004 10:27 AM
how do I copy a whoel folder form one directory to another form the command line? zwyrbla Linux - Newbie 8 08-24-2004 06:40 PM
Simple php script with html form not working. sinsoush Programming 4 04-01-2004 08:02 PM
Simple PHP form not working... Booster Programming 4 02-23-2004 02:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration