ParseNumbers works ugly
Imperat opened this issue · comments
Hello, authors!
I have the form with inputs which has types "text" and "number".
When I use serializeJSON() method with argument "ParseNumbers:true", your plugin parse me all data which user input. (also data with type=text).
When I set ParseNumbers:false, your plugin doesn't parse anything..There is ability to depend of "type" of input? Thanks!
The plugin doesn't look at the input type. The types that the plugin handles are self-defined in the plugin.
See the :types
section in the README.
All fields are parsed as :string
by default. The parseNumbers: true
option automatically detects and convert strings like "1", "33.33", "-44" to numbers like 1, 33.33, -44. None of this has anything to do with the input type. The input type is for HTML5 browsers.
It seems like you want to define your own types, do it with the :types
sufix like this:
<input type="text" name="username:string" value="Imperat"/>
<input type="number" name="issues:number" value="1"/>
$('input').serializeJSON();
// returns =>
{
"username": "Imperat",
"issues": 1
}
Ok, now it's clear for me. Thanks for your reply!