|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| 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
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
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 |
|
||||
|
Hmmm...
Either the question is too stupid, or nobody knows the answer... Thanks for the help
__________________
http://www.aventurevoyages.com |
|
||||
|
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
Code:
var Some_Field = document.Some_Form.Some_Field.value;
if (Some_Tield == '') {
alert ("You didn't fill out Some_Field, dummy!");
}
__________________
Toronto Web Design | Search Engine Friendly, Standards-Compliant Layouts | Walk on my Path (my blog) |
|
|||
|
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. |
|
||||
|
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.
__________________
Toronto Web Design | Search Engine Friendly, Standards-Compliant Layouts | Walk on my Path (my blog) |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |