Jquery data function remove null from start of string

I have something like this:

<input id="zip_code" type="text" value="" data-existing-value="09458" name="zip_code"/>


I am trying to get the existing zip code value from a data parameter using:



And for some reason the null is removed ... and all I get for the textbox value is "9458" with no leading zero ...

How can I store zero?


source to share

2 answers

Try it . attr () instead of . data ()





You must use attr('data-existing-value')





All Articles