HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 25th, 2004, 02:29 PM
senrag senrag is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 senrag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Please help with form

Hi there I want this form to do client side validation by checking that the user has entered at least 1 character in each of my fields on the form. The problem is it does not seem to work and jumps through to the asp page and reports an error of 'customers.Password' cannot be a zero-length string. I know this as my database is set for this. But the form should check the fields first before posting to the asp page or am i missing something.

plz be gentle as I am new to this and thank you

<html>
<TABLE WIDTH="600" CELLPADDING="10" CELLSPACING="0" ALIGN="CENTER"
Background="1.jpg" BORDER="2">
<TR>
<TD><BR>
<CENTER>
<script language = "VBScript">

option explicit
private sub chkformdata()
dim tempfirst, templast
dim temppass, tempcity, temppost, temphone
dim tempmail

tempfirst= signup.firstname.value
templast = signup.lastname.value
tempmail = signup.e-mail.value
temppass = signup.password.value
tempcity = signup.city.value
temppost = signup.postcode.value
temphone = signup.homephone.value

if len(tempfirst) = 0 then
msgbox("Sorry you have not entered a valid first name. It

must be at least 1 character long ")
else
if len(templast) = 0 then
msgbox("Sorry you have not entered a valid Last

Name.It must be at least 1 character long ")
else
if len(tempmail) = 0 then
msgbox("Sorry you have not entered a valid E-mail

address.It must be at least 1 character long ")
else
if len(temppass) = 0 then
msgbox("Sorry you have not entered a valid

Password.It must be at least 1 character long ")
else
if len(tempcity) = 0 then
msgbox("Sorry you have not entered a valid

City.It must be at least 1 character long ")
else
if len(temppost) = 0 then
msgbox("Sorry you have not entered a

valid Post Code.It must be at least 1 character long ")
else
if len(temphone) = 0 then
msgbox("Sorry you have not entered a

valid Phone Number.It must be at least 1 character long ")
End if
End If
End If
End if
End if
end if
end if

end sub
</script>
</head>

<BODY text = "yellow" body background="1.jpg" LINK="iceblue"

VLINK="white">
<form name="signup" action="customer.asp" method="post">

<table border=0 cellpadding=0 align=center cellspacing=0

BGCOLOR="navy">
<td>
<tr>

<align=right>First name:
<input type="text" name="FirstName" value="">

<align=right>Last name:
<input type="text" name="LastName" value="">

<align=right>E-Mail:
<input type="text" name="e-mail" value="">

<align=right>Password:
<input type="password" name="password" value="">

<align=right>City:
<input type="text" name="city" value="" value="">

<align=right>Postal Code:
<input type="text" name="postcode" value="">

<align=right>Phone Number:
<input type="text" name="HomePhone" value="">



<input type="submit" value="Submit" align="center" onClick =

"chkformdata()">
<input type="Reset" value="Reset" align="center">

</tr>
</table>
</form>
</html>

Last edited by senrag : May 25th, 2004 at 05:23 PM.

Reply With Quote
  #2  
Old May 26th, 2004, 02:16 AM
Yeruhn's Avatar
Yeruhn Yeruhn is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Netherlands
Posts: 428 Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 16 h 35 m 27 sec
Reputation Power: 10
Your sub must be a function and the function should return false if submitting is not allowed.
And change the input to:
<input type="submit" value="Submit" align="center" onClick = "return chkformdata()">

That should do the trick...

Reply With Quote
  #3  
Old June 15th, 2004, 10:37 AM
sanjanah_verma sanjanah_verma is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 190 sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 7 h 16 m 13 sec
Reputation Power: 6
I have done a similar one using ASP.Just have the data entered by the user stored in some variable like this
<%
firstname=Request.Form("firstname")
lastname=Request.Form("lastname")
......

if firstname="" then
%>
<script language="JavaScript">
alert("Firstname not entered")
</script>
<%
response.end
end if
%>

This will check whether the user has entered some values or skipped it.If the user has not entered any value the program will terminate.The program will be executed one and only if all the conditions given by you are satisfied.

Hope you got some idea.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > Please help with form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway