English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want a way to have my form have a required field so if it's left blank, the form won't be sent and I can control the number of blank e-mails I get sent. Any help? I build my own php forms so I'd appreciate it if you wouldn't suggest an online form maker or generator, I love having my site being built solely by me.

2007-05-01 10:48:39 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

What you want to use is Javascript to do some client side checking before the user can click a submit button. This W3 Schools link has pretty much the exact example that you are looking to implement:

2007-05-01 10:55:47 · answer #1 · answered by Jim Maryland 7 · 1 0

what's to be wondered is the technique of allowing those women to construct their shallowness, conquer their insecurities and kind supportive courting. Can or might want to someone be the pioneer. I actually have seen you Tyra do it on your first teach (the females camp you began contained in the States) I seen in Malaysia. even even though it develop into in the back of agenda with the help of months i develop into enthralled with the help of the prospect of having the ability to help the females you meant by your own way. and that i'll assert it back: "What are the ability accessible for some communities to help those women?" we are all born with a purpose in this international, abilities, recommendations, strengths and weaknesses. The media does undesirable harm to youthful impressionable minds. although, I actually have talked about those days that there are extra classified ads and extra idols being advertised that are not any more the twiglet skinny form. that is a good commence yet we favor even extra range in that aspect. the mission with the media is they don't let human beings see the reality purely the completed product .. those so reported as fashions have flaws a twin of honestly everyone.

2016-11-24 19:07:38 · answer #2 · answered by Anonymous · 0 0

It depends on what you're using to handle the form data. Form handling scripts allow you to put a hidden field called 'required' and list the fields that you want to be required. Like this:

This doesn't effect making the form yourself.

2007-05-01 10:56:33 · answer #3 · answered by dubbarob 5 · 0 0

////////////////////////////////////////////////////////////////////////////////////////////
script type="text/javascript">
function ok() {
if(document.myform.foo.value.length > 0)
return true;
} else {
alert('You must include Foo');
document.myform.foo.focus();
return false;
}
}


name="myform">
Foo:
...



This could be enhanced with some additional checks for the value, e.g. for complying with some specific format (like letters only, or whatever). Note that the attribute value="" is there to make it explicit and sure that the field's initial value is empty and not just undefined. (Probably most browsers use empty initial value anyway, but personally I feel more comfortable when I've made it sure. :-) )
//////////////////////////////////////////////////////////////////////////////////////////////
Make a form field required

--------------------------------------------------------------------------------

In this example I will show you how to make a form field required before allowing it to be processed. In this example we will use a self submitting form using a case statement.

Dim Variable name '(ShowAction)
ShowAction = Request.QueryString("action")
'QueryString (what shows in the address of bar) exampe.asp?action=show&error="&strerr&""

Key componets of a Case statement

Select Case ShowAction
Case ""
...
'Show Form
...
Case "show"
'process form
...
'end of process
End Select


According to how the fields are entered the following is processed.
if strerr = "1" then
response.write "Please fill in the field!"
end if

if strerr = "2" then
response.write "Please fill in the field!"
end if

if strerr = "3" then
response.write "Please fill in the field!"
end if

When the form is being processed then the following will be applied

if strfname = "" and strlname <> "" then
response.redirect "example.asp?error=1"
end if
if strfname <> "" and strlname = "" then
response.redirect "example.asp?error=2"
end if
if strlname = "" and strfname = "" then
response.redirect "example.asp?error=3"
end if

If both fields are enter then strerr will = blank and then process the rest of the form and give you your results.

Response.write "Hi " & strfname & "" & strlname & "
"


Code:
-------------------------------------------------------

<%@Language = VBScript %>
<% Option Explicit %>


Required field example



<%

'dim your variables
dim ShowAction, strerr, strfname, strlname

ShowAction = request.QueryString("action")
strerr = request.QueryString("error")
strfname = request.form("fname")
strlname = request.form("lname")

'load the form page
Select Case ShowAction
Case ""

'list our error codes and descriptions
if strerr = "1" then
response.write "Please enter your first name!"
end if

if strerr = "2" then
response.write "Please enter your last name!"
end if

if strerr = "3" then
response.write "Please in both fields!"
end if
response.write strfname
%>



Enter your name: " name="fname" size="10" maxlength="10">

Enter your last name: " name="lname" size="30" maxlength="40">







<%
'User has hit submit
Case "show"
Session("fname") = strfname
Session("lname") = strlname

if strfname = "" and strlname <> "" then
response.redirect "example.asp?error=1"
end if
if strfname <> "" and strlname = "" then
response.redirect "example.asp?error=2"
end if
if strlname = "" and strfname = "" then
response.redirect "example.asp?error=3"
end if

'Show detaills
Response.write "Hi " & strfname & "" & strlname & "
"

case "clear"
Session.Abandon
response.redirect "example.asp"

End Select
%>


//////////////////////////////////////////////////////////////////////////////////////////////

2007-05-01 10:53:40 · answer #4 · answered by Shaifu 3 · 0 0

fedest.com, questions and answers