iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-16-2005, 03:37 AM
aventvoy's Avatar
WebProWorld Member
 
Join Date: Jul 2003
Location: Vancouver
Posts: 48
aventvoy RepRank 0
Default Mandatory fields in a form (formmail)

Hello,
I would like a few fields on a form (formMail) to become mandatory and a page to pop up if one field is not filled.
Could someone help me on this? for instance on

<td width="142">Name</td>
<td width="118"><input name="name" type="text" id="name"></td>
<td width="142">Address</td>
<td width="118"> <input name="adresse" type="text" id="adresse"> </td>

I have tried different formulas, looked for the same question here... Couldn't get it to work...

Thanks a lot!
__________________
http://www.aventurevoyages.com
Reply With Quote
  #2 (permalink)  
Old 11-17-2005, 12:49 AM
aventvoy's Avatar
WebProWorld Member
 
Join Date: Jul 2003
Location: Vancouver
Posts: 48
aventvoy RepRank 0
Default

Hmmm...
Either the question is too stupid, or nobody knows the answer...
Thanks for the help
__________________
http://www.aventurevoyages.com
Reply With Quote
  #3 (permalink)  
Old 11-17-2005, 01:31 AM
ADAM Web Design's Avatar
WebProWorld 1,000+ Club
 
Join Date: Dec 2003
Location: Toronto, Ontario, Canada
Posts: 2,181
ADAM Web Design RepRank 1
Default

It's not too stupid a question. The problem with it is that the answer varies depending on the language you want to use.

It could be done on the server side, using ASP or PHP or .NET or even CGI or Perl. It can also be done using Javascript on the client side.

The reason you can't find a formula is because there is no set formula. It's going to depend on your form and the type of validation you want.

For example, in ASP your form validation might look something like this:
Code:
Dim Some_Field
Some_Field = Request.Form ("Some_Field")
if Some_Field = "" or IsNull (Some_Field) then
    Response.Write "

You left Some_Field blank, jackass.</p>"
end if
Alternatively, in Javascript you might end up with something like this:
Code:
var Some_Field = document.Some_Form.Some_Field.value;
if (Some_Tield == '') {
    alert ("You didn't fill out Some_Field, dummy!");
}
This is more of an application question than a syntax question, so you're not likely to get an answer in general terms.
Reply With Quote
  #4 (permalink)  
Old 11-17-2005, 01:36 AM
WebProWorld Member
 
Join Date: Sep 2005
Posts: 82
sysop9999 RepRank 0
Default

It can be done with javascript, but I'm not that much of an expert on that.

I usually do it like this (using ASP):

<form method="POST" action="check.asp">
....
.....rest of the form fields....
.....

And on the check.asp page I run through the form collection to see if any of the fields are missed out, and return an error if this is the case.

like:

Code:
<%
dim kon
for each kon in request.form
 if request.form.item(kon) = "" then
%>
error in form - please hit backbutton and fill out all required fields.
<%end if
next
%>
All went well .... have a nice day.
I haven't tried this one though, but that's how I'd perform the task.
__________________
Kim B. Juul
Danish Web Design & SEO
Reply With Quote
  #5 (permalink)  
Old 11-17-2005, 01:45 AM
ADAM Web Design's Avatar
WebProWorld 1,000+ Club
 
Join Date: Dec 2003
Location: Toronto, Ontario, Canada
Posts: 2,181
ADAM Web Design RepRank 1
Default

Gotta love the ASP form collection. I found out about both that and the Execute function 2.5 years ago. Now I have an include file with 2000 lines of precompiled code based on both of those ideas (and other form validation/generation/other stuff), and each of my pages is now about 20 lines.

Sweeeeeeet.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:17 PM.



Search Engine Optimization by vBSEO 3.3.0