|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Quote:
No. How do I do that? |
|
#4
|
|||
|
|||
|
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
|
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
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 ![]() |
|
#7
|
||||
|
||||
|
from line 22 remove end if. then it will work fine
Quote:
|
|
#8
|
|||
|
|||
|
cool thanks, that helped lots = )
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > validating problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|