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

Call A Script Function Problem

Status
Not open for further replies.

1Data

MIS
Sep 30, 2005
66
US
I am making a call to a VBScript called Validate.vbs. There is a Function within this script that is called validateNumeric(strValue). I keep getting a Type mismatch: 'validateNumeric'

here is my code..

If Form.purchaseprice1.value = "" Then 'If Null then Nothing Else Check
Else
Dim strValue
strValue = (Form.purchaseprice1.value)
intcheck = Sgn(Form.purchaseprice1.value)'Checking that Num is Positive
If intcheck = 1 Then
Dim intValue
intValue =(Form.purchaseprice1.value) 'Checking Length
msgBox intValue
If validateNumeric(intValue) Then
msgBox "Yes Boyeeee!"
End If
End If
End If

And here is my function...

function validateNumeric(strValue )
Set re = New RegExp
With re
'.Pattern = "(^-?\d\d*$)(\d{10})\.\d{1,2}$)"
.Pattern = "\d{10}"
.IgnoreCase = True
.Global = True
End With
'Boolean expressionmatch
expressionmatch = re.Test(strValue)
validateNumeric = expressionmatch
end function

If anyone can offer some advice i would appreciate it...It's not that value strValue being passed I know that to be a fact..I think it's the way I am calling the function which I have done before but now it is erroring out...
 
Is there something wrong with the builtin VBS IsNumeric function?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
No but I wanted to use Regular Expressions more for future formatting issues. The problem is on the call to the script not so much the formatting...
 
Well it appears to be working for me. You realize of course that the pattern you are using will only be valid for a 10 digit number with no decimals? Unfortunately, without being able to reproduce the error I would have a hard time finding it. All I can suggest are generic troubleshooting things.

If you have On Error Resume Next in your script, comment it out. Use messageboxs to confirm what you are trying to pass to the function. Use the VarType and TypeName functions to help determine what you are passing to the function.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I realize that the expression is what you mentioned, that's not important to me right now...I have another question though in my HTML tags I am using this..

<SCRIPT Language="VBScript" src="/Validate.vbs"></SCRIPT>
<SCRIPT language="VBScript">
<!--

...

<\SCRIPT>

The Validate.vbs is the script file, when I place the function within the script it works fine. It's just when I want to call it off of this Validate.vbs file that is located in the same folder that I have my project in...thus the 1 / in the src? This thing is killing me...thanks for your help up to this point though...
 
Well I did find one potential problem. Sgn() requires a valid numerical expression for an input. In theory that will give you an error if the field has invalid text in it.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
that works fine...it returns a 1...plus I have tried this with everything commented out to make certain that it's not something like that...I have made the call to the function by itself and it still faults out..
 
[1]
>[tt]<SCRIPT Language="VBScript" src="[highlight]/[/highlight]Validate.vbs"></SCRIPT>[/tt]
It means your validate.vbs must be located at the root of your site. Make sure you understand the meaning.
[2]
The validate.vbs must not contain something like <script> tag for instance.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top