Ecco cosa ho fatto:
codice:
<input type="text" name="prezzo" size="27" onchange="vbscript:formattazione prezzo" onkeyup="vbscript: validatore prezzo,'float'">
codice:
function formattazione(C1)
trovato=0
txt=cstr(C1.value)
if len(txt)=0 then
C1.value=0
else
for i=1 to len(txt)
c=mid(txt,i,1)
if c="." then trovato=trovato+1
if c="," then trovato=trovato+1
next
if trovato=2 then
C1.value=Replace(C1.value,".","")
else
C1.value=Replace(C1.value,".",",")
end if
end if
C1.value=FormatNumber(C1.value,2)
end function
function validatore(campo,tipo)
txt=cstr(campo.value)
campo.value=""
for i=1 to len(txt)
c=mid(txt,i,1)
errore=0
select case lcase(tipo)
case "int"
if not isnumeric(c) then errore=1
case "float"
if not isnumeric(c) and c<>"." and c<>"," then errore=1
end select
if errore=0 then campo.value=campo.value&c
next
end function
Adesso però l'evento onChange non parte più, perchè???