When passing a value to the background, 0 is a text, 1 is an integer, and 2 is a floating point number. How can you tell what the current state is?

clipboard.png
three different states

        let data=[]
            var shuzhi= document.getElementsByTagName("input");
            for(var i=0;i<shuzhi.length;iPP){
                    var obj={
                    valueId: shuzhi[i].getAttribute("id"),
                    valueTime:time,
                    value: shuzhi[i].value,
                    valueType:valueType,
                    reportId:1
                }
                    data.push(obj);
            }

valueType 0 is text 1 is an integer 2 is a floating point number how can I tell?

Mar.04,2021

use typeof to determine character types


  1. / ^ [0-9] + $/
  2. shuzhi.indexOf ('.')

the rest are 0


doesn't understand what you're asking.
what do you mean by judgment?
according to the code you give now, valueType is already a definite value, and you can judge by valueType, or you need to derive valueType? according to some other values.

Menu