|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
found the problem...
there was an form some where else on the page that didn't end with </FORM> |
|
#3
|
||||
|
||||
|
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 |
|
#4
|
||||
|
||||
|
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 ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Check form fields: submit if not empty |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|