SunQuest
 
           JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old October 12th, 2006, 07:45 AM
majesticzero majesticzero is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 15 majesticzero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 5 sec
Reputation Power: 0
Check form fields: submit if not empty

Hi everybody!

I want Javascript to check if a form field is not empty.

this is my form:

Code:
<table CLASS="Admin">
	<form action="hideout/news/processNews.php?action=addNews" method="post" enctype="multipart/form-data" name="frmAddNews">
	<tr><TH id="header" COLSPAN="2">Nieuws toevoegen
	<tr> 
		<td width="150" >Titel
		<td><input name="txtTitle" type="text" id="input" size="50" maxlength="100">
	<tr> 
		<td width="150" >omschrijving
		<td> <textarea name="mtxMessage" cols="70" rows="10" id="input"></textarea>
	<tr> 
		<td width="150" >Afbeelding
		<td><input name="img" type="file" id="input"> 
	<TR>
		<TD COLSPAN='2' ALIGN='center'>
			<input name="btnAddNews" type="button" id="button" value="Toevoegen" onClick="checkAddNewsForm();">
			<input name="btnCancel" type="button" id="button" value="Terug" onClick="window.location.href='?action=hideout_news';"> 
	</TABLE>


and this is my javascript.js file:

Code:
function checkAddNewsForm(){
	with (window.document.frmAddNews){
		if (frmAddNews.txtTitle.value == "") {
			alert("Vul een titel in.");
			return;
		}
		if (frmAddNews.mtxMessage.value == "") {
			alert("Vul een omschrijving in.");
			return;
		}
		else {
			submit();
		}
	}
}


I load the javascript from an external .js file

The javascript.js file works with other functions so the location is correct.

When I leave a field empty the popup message is not shown and the page DOES NOT submit.

my table is in a file called "add.php".
it is included in a file called "Administration".
like this:

Administration page:
- click on the link "Add News"
- add.php is included in the administration page trough a php command.

the problem is that add.php on it's self DOES work. but when included in the administration page it doesn't.

does someone know what's wrong here?

Reply With Quote
  #2  
Old October 12th, 2006, 09:18 AM
majesticzero majesticzero is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 15 majesticzero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 5 sec
Reputation Power: 0
found the problem...

there was an form some where else on the page that didn't end with </FORM>
Comments on this post
MadCowDzz agrees: Thanks for the followup!

Reply With Quote
  #3  
Old October 13th, 2006, 07:57 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Thanks for following up... hopefully this helps others with similar situations.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #4  
Old October 13th, 2006, 07:58 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 471 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 9 m 44 sec
Reputation Power: 3
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
also for more help for ANYONE with javascript and html moreso, but ms-dos and java, you could contact me at colton22@comcast.net

colton22


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Check form fields: submit if not empty


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway