Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

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 January 9th, 2005, 05:25 PM
~sikka~ ~sikka~ is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Norway
Posts: 38 ~sikka~ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 44 sec
Reputation Power: 5
validating problems

Hi.

My coding must be wrong cuz my form validates no matter how many errors I put in there. Can someone please enlighten me in what stupid thing I have done wrong?

Code:
option explicit
  Function frmSkjema_onSubmit()
  dim strBrukernavn, strPassorden, strPassordto
  dim strMellomromsjekk
  
  strBrukernavn = frmSkjema.txtBrukernavn.value
  strPassorden = frmSkjema.txtPassorden.value
  strPassordto = frmSkjema.txtPassordto.value
  
  if strBrukernavn = "" then
   document.write = "Brukernavn må fylles ut"
    frmSkjema_onSubmit = false
  else 
  strMellomromsjekk = fjerneMellomrom (strBrukernavn)
  if sjekkFortall(strBrukernavn) then
  	document.write= "Brukernavn kan ikke inneholde tall"
    frmSkjema_onSubmit = false
  end if
  
  if strPassorden = "" then
  	document.write = "Passord må fylles ut"
  	frmSkjema_onSubmit = false
  	if
  	strPassorden length = >5 AND <8
  	frmSkjema_onSubmit = false
  else
  strMellomromsjekk = fjerneMellomrom (strPassorden)
  end if
  
  if strPassordto = "" then
  	document.write = "Passord må bekreftes"
  	frmSkjema_onSubmit = false
  	else
  	if strPassordto = strPassorden then
  strMellomromsjekk = fjerneMellomrom (strPassordto)
  frmSkjema_onSubmit = true
  end if
  	
  End function
  
  function sjekkFortall(streng)
    dim intMax, i
    intMax = len(streng)
    sjekkForTall = False
    for i = 1 to intMax
  	if IsNumeric(mid(streng,i,1)) then
  	sjekkForTall = true
  	end if
    next
  end function
  
  function fjernMellomrom (streng)
    dim intMax, i, strTemp
    intMax = trim(len(streng))
    for i = 1 to intMax
  	strTemp = mid (streng,i,1)
  	if not strTemp = " " then
  	  fjernMellomrom = fjernMellomrom & strTemp
  	end if
    next
  end function

Reply With Quote
  #2  
Old January 9th, 2005, 11:41 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Have you tried stepping through your code with the debugger?
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old January 10th, 2005, 07:12 AM
~sikka~ ~sikka~ is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Norway
Posts: 38 ~sikka~ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 44 sec
Reputation Power: 5
Quote:
Originally Posted by Doug G
Have you tried stepping through your code with the debugger?


No. How do I do that?

Reply With Quote
  #4  
Old January 10th, 2005, 08:54 AM
~sikka~ ~sikka~ is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Norway
Posts: 38 ~sikka~ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 44 sec
Reputation Power: 5
I tried option explicit now if thats what you meant, and found a couple of errors... but one thing I dont understand whats wrong is this:

in line 23 its expecting and "end" - i dont understand where it needs an end right there.

line 23 is this:
Code:
  19 if strBrukernavn = "" then
  20 document.write = "Brukernavn må fylles ut"
  21  frmSkjema_onSubmit = false
  22 end if
  23 else 
  strMellomromsjekk = fjerneMellomrom (strBrukernavn)
  if sjekkFortall(strBrukernavn) then
  	document.write= "Brukernavn kan ikke inneholde tall"
    frmSkjema_onSubmit = false
  end if
  


Code:
  <script type="text/vbscript">
  <!--
  option explicit
  function frmSkjema_onSubmit()
  dim strBrukernavn, strPassorden, strPassordto
  dim strMellomromsjekk
  
  strBrukernavn = frmSkjema.txtBrukernavn.value
  strPassorden = frmSkjema.txtPassorden.value
  strPassordto = frmSkjema.txtPassordto.value
  
  if strBrukernavn = "" then
   document.write = "Brukernavn må fylles ut"
    frmSkjema_onSubmit = false
  end if
  else 
  strMellomromsjekk = fjerneMellomrom (strBrukernavn)
  if sjekkFortall(strBrukernavn) then
  	document.write= "Brukernavn kan ikke inneholde tall"
    frmSkjema_onSubmit = false
  end if
  
  if strPassorden = "" then
  	document.write = "Passord må fylles ut"
  	frmSkjema_onSubmit = false
  	end if
  	else
  if strPassorden <8 then
  document.write = "Passordet må være mindre enn 8 tegn"
  	frmSkjema_onSubmit = false
  	end if
  else
  if strPassorden >5 then
  document.write = "Passordet må være mer enn 5 tegn"
  	frmSkjema_onSubmit= false
  end if
  	else
  strMellomromsjekk = fjerneMellomrom (strPassorden)
  end if
  
  if strPassordto = "" then
  	document.write = "Passord må bekreftes"
  	frmSkjema_onSubmit = false
  end if
  	else
  	if NOT strPassordto = strPassorden then
  document.write = "Passordene må være de samme, prøv på nytt"
  frmSkjema_onSubmit = false
  end if 
  else
  strMellomromsjekk = fjerneMellomrom (strPassordto)
  frmSkjema_onSubmit = true
  end if
  end if	
  
  end function
  
  function sjekkFortall(streng)
    dim intMax, i
    intMax = len(streng)
    sjekkForTall = False
    for i = 1 to intMax
  	if IsNumeric(mid(streng,i,1)) then
  	sjekkForTall = true
  	end if
    next
  end function
  
  function fjernMellomrom (streng)
    dim intMax, i, strTemp
    intMax = trim(len(streng))
    for i = 1 to intMax
  	strTemp = mid (streng,i,1)
  	if not strTemp = " " then
  	  fjernMellomrom = fjernMellomrom & strTemp
  	end if
    next
  end function
  exit function

Reply With Quote
  #5  
Old January 10th, 2005, 05:02 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
What version of VB?

Normally, in your code editing window you can click on the left margin to set a breakpoint on a line of code. Then when you run your code from within your development IDE, the debugger will open when your code runs across the breakpoint, and you can step through a line at a time.

Look in your VB online help for detailed information on using your debugger.

Reply With Quote
  #6  
Old January 11th, 2005, 05:37 AM
~sikka~ ~sikka~ is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Norway
Posts: 38 ~sikka~ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 44 sec
Reputation Power: 5
oh... you mean its a program called Visual Basic? ... I thought this was the forum to ask questions in if I had problems with VBscript (thought VBscript meant visual basic script)...

I do my coding in dreamweaver.
Sorry about posting in the wrong forum then, guess I cant get any help in here

Reply With Quote
  #7  
Old January 13th, 2005, 12:30 AM
hithere's Avatar
hithere hithere is offline
Learner
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: India
Posts: 450 hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 12 h 13 m 21 sec
Reputation Power: 17
from line 22 remove end if. then it will work fine

Quote:
Originally Posted by ~sikka~
I tried option explicit now if thats what you meant, and found a couple of errors... but one thing I dont understand whats wrong is this:


in line 23 its expecting and "end" - i dont understand where it needs an end right there.

line 23 is this:
Code:
19 if strBrukernavn = "" then
20 document.write = "Brukernavn må fylles ut"
21 frmSkjema_onSubmit = false
22 end if
23 else 
strMellomromsjekk = fjerneMellomrom (strBrukernavn)
if sjekkFortall(strBrukernavn) then
	document.write= "Brukernavn kan ikke inneholde tall"
frmSkjema_onSubmit = false
end if


Code:
<script type="text/vbscript">
<!--
option explicit
function frmSkjema_onSubmit()
dim strBrukernavn, strPassorden, strPassordto
dim strMellomromsjekk
 
strBrukernavn = frmSkjema.txtBrukernavn.value
strPassorden = frmSkjema.txtPassorden.value
strPassordto = frmSkjema.txtPassordto.value
 
if strBrukernavn = "" then
document.write = "Brukernavn må fylles ut"
frmSkjema_onSubmit = false
end if
else 
strMellomromsjekk = fjerneMellomrom (strBrukernavn)
if sjekkFortall(strBrukernavn) then
	document.write= "Brukernavn kan ikke inneholde tall"
frmSkjema_onSubmit = false
end if
 
if strPassorden = "" then
	document.write = "Passord må fylles ut"
	frmSkjema_onSubmit = false
	end if
	else
if strPassorden <8 then
document.write = "Passordet må være mindre enn 8 tegn"
	frmSkjema_onSubmit = false
	end if
else
if strPassorden >5 then
document.write = "Passordet må være mer enn 5 tegn"
	frmSkjema_onSubmit= false
end if
	else
strMellomromsjekk = fjerneMellomrom (strPassorden)
end if
 
if strPassordto = "" then
	document.write = "Passord må bekreftes"
	frmSkjema_onSubmit = false
end if
	else
	if NOT strPassordto = strPassorden then
document.write = "Passordene må være de samme, prøv på nytt"
frmSkjema_onSubmit = false
end if 
else
strMellomromsjekk = fjerneMellomrom (strPassordto)
frmSkjema_onSubmit = true
end if
end if	
 
end function
 
function sjekkFortall(streng)
dim intMax, i
intMax = len(streng)
sjekkForTall = False
for i = 1 to intMax
	if IsNumeric(mid(streng,i,1)) then
	sjekkForTall = true
	end if
next
end function
 
function fjernMellomrom (streng)
dim intMax, i, strTemp
intMax = trim(len(streng))
for i = 1 to intMax
	strTemp = mid (streng,i,1)
	if not strTemp = " " then
	 fjernMellomrom = fjernMellomrom & strTemp
	end if
next
end function
exit function

Reply With Quote
  #8  
Old January 13th, 2005, 04:40 PM
~sikka~ ~sikka~ is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Norway
Posts: 38 ~sikka~ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 44 sec
Reputation Power: 5
cool thanks, that helped lots = )

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > validating problems


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 3 hosted by Hostway
Stay green...Green IT