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

Validation Help

Status
Not open for further replies.

ukwebsite

Programmer
Dec 9, 2000
82
GB
Please help. I have an ASP page posting data into an access database. One of the fields is a currency field.

On my local development server if I enter a £ sign it works fine. The access database field is set to currency and the value is stored. On the live server I get an error if I include the £ sign. I think it might be because the server is not setup for the UK locale as the hosting company is based in Germany.

Is there a way to change the locale for my web site within my code?

OR

I use an isNumeric validation code to ensure its numeric but this allows the £ sign. Is there a way to disallow the £ sign.


The validation code is

function isPURPRICE(val)
if len(val.value)>0 then
if isNumeric(val.value) then
isPURPRICE= true
else
msgbox "PURCHASE PRICE - PLEASE USE ONLY NUMBERS E.G. £50,000 = 50000"
val.select
isPurprice = false
end if
else
isPurprice = true
END IF
end function

Thanks


Matthew Wilde
matthew@ukwebsite.com
 
use the Locale ID and set session.LCID = 2057 on the page to use UK settings.

you could use a replace(strIn,"£","") to remove the £ sign or a regular expression to replace currency symbols and commas
Code:
function ReplaceCurrency(strIn)
' function to remove currency symbols
	dim objRE
	set objRE= New RegExp
	objRE.Pattern = "[$£,]"
	objRE.Global = True
	ReplaceCurrency = objRE.replace(strIn, "")
	set objRE= nothing
end function

reg ex to validate numbers only
Code:
function CheckNumeric(strIn)
' function to validate numeric input
' return true if all chars are between 0 to 9
	dim objRE
	set objRE = New RegExp
	objRE.Pattern = "^[0-9]"
	objRE.Global = True
	CheckNumeric = objRE.test(strIn)
	set objRE = nothing
end function



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Thanks but the session.lcid just determins the format the datte is displayed it doesn't change the time zone.

I have found the code to do this so I will post it in case others have the problem

TimeDiff = (DateAdd("h","-1", Now))
TimeAray = Split(TimeDiff, " ")
Response.write(TimeAray(0)) & " " & TimeAray(1)

I will now look at the other problem. Once again thanks for your help.

Matthew Wilde
matthew@ukwebsite.com
 
How do i call the function CheckNumeric(strIn)please?

Matthew Wilde
matthew@ukwebsite.com
 
No the LCID doesn't change the time zone, what it does is set ALL regional display setting to use the LCID specified one. So FormatDateTime() and FormatCurrency() with LCID = 2057 will return UK settings (dd/mm/yy and "£").

Use CheckNumeric() example

Code:
dim bNumeric
dim InputValue : InputValue = 50000

bNumeric = CheckNumeric(InputValue)
' bNumeric will = true

InputValue = "£50000"
bNumeric = CheckNumeric(InputValue)
' bNumeric will = false


Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top