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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validation logic help

Status
Not open for further replies.

matrixxx

MIS
Oct 30, 2001
12
0
0
US
Hello,

the following validation is giving me problems when it checks for the number of numbers entered in the phone field. The script checks first to see if the field is not empty, then checks to make sure its numeric. both seem to work fine. the next if statement checks to make that there is at least 10 numbers. which i can't get to work. what I am trying to achieve is to generate an error if less then 10 numbers are in the field. the max length is controled by the input form.

Sub Check_Phone(fvalue,dname)
If (fvalue) = "" then
ErrCount=ErrCount+1
AddErr(Cstr(ErrCount) + ". "+ dname+ " cannot be empty")
else

If IsNumeric(Trim(fvalue))=False Then
ErrCount=ErrCount+1
AddErr(CStr(ErrCount) + ". " + dname + " is not a valid Number")
else

if len(fvalue) < 10 then
ErrCount=Errcount+1
AddErr(CStr(ErrCount) + &quot;. &quot; + dname + &quot;doesn't appear to be a valid phone no.&quot;)

End IF
End If
End If
End Sub


any help or recommendations would be appreciated
 
Could it be that VBScript has determined that fvalue is a number? If so, maybe explicit typing will solve the problem.

len(CStr(fvalue))

Just an idea.
 
when i input a value(1234) it doesn't appear to work. the strange part is, when i return to the input page there is an error that the phone no. doesn't appear to be a valid number. my script is suppose to maintain the values and let the user resubmit. but it submitted, so the fields were empty. this is so strange. it only started doing this after i added the 3rd if statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top