Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

required field in a form

Status
Not open for further replies.

laonei

Technical User
Feb 21, 2005
11
FR
Hi,

I need to make four required fields for a script. But with asp, I don't know how to make it. Someone can help?

script of session:


Session("Erreur")=""
Session("txbNom")=Request.Form("txbNom")
Session("txbPrenom")=Request.Form("txbPrenom")
Session("txbAdresse")=Request.Form("txbAdresse")
Session("txbAdressePostale")=Request.Form("txbAdressePostale")+" "
Session("txbCodePostal")=Request.Form("txbCodePostal")+" "
Session("txbVille")=Request.Form("txbVille")+" "
Session("txbPays")=Request.Form("txbPays")+" "
Session("NatureInscription")=Request.Form("optSujet")
indOk=true
If Request.Form("txbNom") = "" Then
IndOk=false
end if
If Request.Form("txbPrenom") = "" Then
IndOk=false
end if
If Request.Form("txbAdressePostale") = "" Then
IndOk=false
End if
If Request.Form("txbCodePostal") = "" Then
IndOk=false
End if
If Request.Form("txbVille") = "" Then
IndOk=false
End if

Thanks,
Laonei
 
did you mean something like this...

If Request.Form("txbCodePostal")="" Then

Response.Write "Please fill in the Postal Code"

End if

-DNG

 
or using javascript...

<form name=myform action=mypage.asp method=post onsubmit="javascript:return ValidateForm(this)">

function ValidateForm(myform)
{
if(IsEmpty(myform.txbCodePostal))
{
alert('You have not entered postal code')
myform.txbCodePostal.focus();
return false;
}
return true;

}


-DNG
 
Hi DNG,

Thaks for your reply.

I changed as you wrote it, and got another error:

Microsoft VBScript error '800a0400'.

I have to say that I had:

If IndOk then

(just after

If Request.Form("txbVille") = "" Then
IndOk=false
End if

What should I write?

 
did u mean this...

If NOT IndOk Then
Response.Write "txbVille Cannot be Empty"
End if

-DNG

 
Original is:
session("incomplet")=false
if Request("Action")="Enregistrement" then
' #### Validation de l'enregistrement sur la liste #####
Session("Erreur")=""
Session("txbNom")=Request.Form("txbNom")
Session("txbPrenom")=Request.Form("txbPrenom")
Session("txbAdresse")=Request.Form("txbAdresse")
Session("txbAdressePostale")=Request.Form("txbAdressePostale")+" "
Session("txbCodePostal")=Request.Form("txbCodePostal")+" "
Session("txbVille")=Request.Form("txbVille")+" "
Session("txbPays")=Request.Form("txbPays")+" "
Session("NatureInscription")=Request.Form("optSujet")
indOk=true
If Request.Form("txbNom") = "" Then
IndOk=false
end if
If Request.Form("txbPrenom") = "" Then
IndOk=false
end if
If Request.Form("txbAdressePostale") = "" Then
IndOk=false
End if
If Request.Form("txbCodePostal") = "" Then
IndOk=false
End if
If Request.Form("txbVille") = "" Then
IndOk=false
End if

if indOK then

@@@

I changed it to:
<%
session("incomplet")=false
if Request("Action")="Enregistrement" then
' #### Validation de l'enregistrement sur la liste #####
Session("Erreur")=""
Session("txbNom")=Request.Form("txbNom")
Session("txbPrenom")=Request.Form("txbPrenom")
Session("txbAdresse")=Request.Form("txbAdresse")
Session("txbAdressePostale")=Request.Form("txbAdressePostale")+" "
Session("txbCodePostal")=Request.Form("txbCodePostal")+" "
Session("txbVille")=Request.Form("txbVille")+" "
Session("txbPays")=Request.Form("txbPays")+" "
Session("NatureInscription")=Request.Form("optSujet")
If Request.Form("txbNom") = "" Then
Response.Write "Merci de rentrer votre nom"
end if
If Request.Form("txbPrenom") = "" Then
Response.Write "Votre Prénom s'il vous plaît"
end if
If Request.Form("txbAdressePostale") = "" Then
Response.Write "Votre Adresse Postale"
End if
If Request.Form("txbCodePostal") = "" Then
Response.Write "Votre Code Postal"
End if
If Request.Form("txbVille") = "" Then
Response.Write "Dans quelle ville habitez-vous?"
End if

else
%>
And I still get the same error.

Sorry for bothering...
 
something like this:

Code:
<%
session("incomplet")=false
if Request("Action")="Enregistrement" then
    ' #### Validation de l'enregistrement sur la liste #####
    Session("Erreur")=""
    Session("txbNom")=Request.Form("txbNom")
    Session("txbPrenom")=Request.Form("txbPrenom")
    Session("txbAdresse")=Request.Form("txbAdresse")
    Session("txbAdressePostale")=Request.Form("txbAdressePostale")+" "
    Session("txbCodePostal")=Request.Form("txbCodePostal")+" "
    Session("txbVille")=Request.Form("txbVille")+" "
    Session("txbPays")=Request.Form("txbPays")+" "
    Session("NatureInscription")=Request.Form("optSujet")
    If Request.Form("txbNom") = "" Then 
     Response.Write "Merci de rentrer votre nom"

Else If Request.Form("txbPrenom") = "" Then 
      Response.Write "Votre Prénom s'il vous plaît"
    
Else If Request.Form("txbAdressePostale") = "" Then 
      Response.Write "Votre Adresse Postale"
Else If Request.Form("txbCodePostal") = "" Then 
      Response.Write "Votre Code Postal"
Else If Request.Form("txbVille") = "" Then 
      Response.Write "Dans quelle ville habitez-vous?"
    End if

'your sql query string here....and all other processing

End if

    
%>
 
oops..it shud be

Else If Request.Form("txbVille") = "" Then
Response.Write "Dans quelle ville habitez-vous?"
End if

else

'your sql query string here....and all other processing

End if
End if

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top