How to create an input for currency or float?
|
Apr '20 |
2 |
943 |
0 |
This is a frontend question and not related to Phalcon in any way... Phalcon operates on server side, unless it's about validation, this question doesn't belong here tbh
Yes I know. I ask about if anything had some special input in Phalcon. The validation trying to do as follows. If anyone has any council would be grateful
<?php echo $this->tag->numericField(array("ART_COSTO", "min"=>"0.00", "step"=>"0.01", "max"=>"9999999999999","value"=>"0.00","onkeyup"=>"puntitos(this,this.value.charAt(this.value.length-1),'')","maxlength"=>"6", "id"=> "fieldArtCosto")) ?>
<script language="JavaScript">
//*VALIDACION DE NUMERO DECIIMAL**
function puntitos(donde, caracter, campo) {
var decimales = false
campo = eval("donde.form." + campo)
for (d = 0; d < campo.length; d++) {
if (campo[d].checked == true) {
dec = new Number(campo[d].value)
break;
}
}
if (dec != 0) {
decimales = true
}
pat = /[\*,\+,\(,\),\?,\\,\$,\[,\],\^]/
valor = donde.value
largo = valor.length
crtr = true
if (isNaN(caracter) || pat.test(caracter) == true) {
if (pat.test(caracter) == true) {
caracter = "\\" + caracter
}
carcter = new RegExp(caracter, "g")
valor = valor.replace(carcter, "")
donde.value = valor
crtr = false
} else {
var nums = new Array()
cont = 0
for (m = 0; m < largo; m++) {
if (valor.charAt(m) == "." || valor.charAt(m) == " ") {
continue;
} else {
nums[cont] = valor.charAt(m)
cont++
}
}
}
if (decimales == true) {
ctdd = eval(1 + dec);
nmrs = 1
} else {
ctdd = 1;
nmrs = 3
}
var cad1 = "",
cad2 = "",
cad3 = "",
tres = 0
if (largo > nmrs && crtr == true) {
for (k = nums.length - ctdd; k >= 0; k--) {
cad1 = nums[k]
cad2 = cad1 + cad2
tres++
if ((tres % 3) == 0) {
if (k != 0) {
cad2 = "" + cad2
}
}
}
for (dd = dec; dd > 0; dd--) {
cad3 += nums[nums.length - dd]
}
if (decimales == true) {
cad2 += "." + cad3
}
donde.value = cad2
}
donde.focus()
}
//* FIN VALIDACION DE NUMERO DECIIMAL*
</script>