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

Validating Numerical Data 1

Status
Not open for further replies.

GWPhoenix

IS-IT--Management
Jun 26, 2001
32
US
I have fields in my program that needs to accept numbers and only numbers (i.e., characters 0123456789). Right now my program as follows sort of shrugs and accepts whatever is put in (FormatData = Value). Anything else I attempt (i.e., Response.Write "Must be numeric") comes out very strange and does not allow for non-entry of fields.

Code:
function FormatData(Value,Format)

const fdCURRENCY=3
		
Format=trim(Format)
Value=trim(Value)
if isnumeric(Format) then
Format=clng(Format)
...


Select Case Format
	Case	fdNUMERIC
	if isnumeric(Value) then
		FormatData=FormatNumber(Value,0)
	else
		FormatData=Value
	end if
	Case Else	'do nothing
		FormatData=Value
End Select
	else
	'if the Format value isn't numeric, just return the original value
	FormatData=Value
		end if
end function

I have a javascript that works quite well for this function on another program. How do I incorporate this javascript with the above VBScript?

 
Hi GWPhoenix,

Just a Point I thought I would mention. Don't rely upon IsNumeric alone to determine whether a Number has been entered in your software.

Isnumeric uses the System Settings for number formats and the IsNumeric Function doesn't treat commas as it should - Bug?

Try entering "34,55,66," or "3456,34,,,,,56" these Formats are classed as Numeric But ARE NOT!

Secondly you can call Javascript and VB functions to each other by simply calling the Function Name.
e.g.

<SCRIPT LANGUAGE=&quot;javascript&quot;>
function txtRateChange_onchange(){
//This Function Takes the Value Entered by the User in the
//Date Field and if Valid,

var sDate;
sDate = DateCheck(txtRateChange.value);
..
}

</SCRIPT>


<SCRIPT LANGUAGE=&quot;vbscript&quot;>
function DateCheck(strDate)

...

end function
</SCRIPT>


Regards,

Codefish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top