{"action":"closed","issue":{"url":"https://api.github.com/repos/BobKnothe/autoNumeric/issues/173","labels_url":"https://api.github.com/repos/BobKnothe/autoNumeric/issues/173/labels{/name}","comments_url":"https://api.github.com/repos/BobKnothe/autoNumeric/issues/173/comments","events_url":"https://api.github.com/repos/BobKnothe/autoNumeric/issues/173/events","html_url":"https://github.com/BobKnothe/autoNumeric/issues/173","id":113694599,"number":173,"title":"autoNumeric can't set values with the current format already applied","user":{"login":"edgedemon","id":5783253,"avatar_url":"https://avatars.githubusercontent.com/u/5783253?v=3","gravatar_id":"","url":"https://api.github.com/users/edgedemon","html_url":"https://github.com/edgedemon","followers_url":"https://api.github.com/users/edgedemon/followers","following_url":"https://api.github.com/users/edgedemon/following{/other_user}","gists_url":"https://api.github.com/users/edgedemon/gists{/gist_id}","starred_url":"https://api.github.com/users/edgedemon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edgedemon/subscriptions","organizations_url":"https://api.github.com/users/edgedemon/orgs","repos_url":"https://api.github.com/users/edgedemon/repos","events_url":"https://api.github.com/users/edgedemon/events{/privacy}","received_events_url":"https://api.github.com/users/edgedemon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-27T21:32:45Z","updated_at":"2015-10-29T21:31:50Z","closed_at":"2015-10-29T21:31:50Z","body":"Hey there.\r\n\r\nWhile working with limeSurvey, i found out that if you try to apply autoNumeric, using the \"init\" function on a text field, which already has formatted text compatible with your current settings, autoNumeric will throw an error.\r\n\r\nthe problem comes from the set Function expecting one single separator char in either \".\" or \",\" regardless on the settings applied. example with default config :\r\n\r\n> $(DEMOFIELD).autoNumeric('set','1,500');    \r\n\r\nwill convert to 1.5 instead of 1500\r\n\r\nand both\r\n\r\n> $(DEMOFIELD).autoNumeric('set','1,000,000');\r\nand \r\n> $(DEMOFIELD).autoNumeric('set','1,000,000.00');    \r\n\r\nwill throw errors.\r\n\r\nalso if you set befere starting autoNumeric it will still fail.\r\n\r\n> $(DEMOFIELD).val('1,000,000');\r\n> $(DEMOFIELD).autoNumeric('init');\r\n\r\nalso throws errors.\r\n\r\nto work around this i replaced line 1139, change this:\r\n\r\n>  value = value.replace(',', '.');\r\n\r\nfor this:\r\n\r\n> value = value.replace(settings.aSep,\"\");\r\n> value = value.replace(settings.aDec, '.');\r\n\r\nor \r\n\r\n> value = value.replace(settings.aSep,\"\");\r\n> value = value.replace(',', '.');\r\n\r\nthat way autoNumeric will first remove its own thousand separator before trying to format.\r\n\r\n"}}