I am looking for a way, with jQuery, to get the default value for an input field (in an HTML field).
It seems simple enough. Just calling $("#id-of-field").attr('value')
should return the value I want correctly?
The thing is, if the value is Foo
, when I load the page, it returns Foo
. No problems. But if I write Bar
in the field, then reload (do not send) the page, $("#id-of-field").attr('value')
will return Bar
me, even if the field value attribute is still Foo
in the source code .
This makes checking my form sticky, because when I get the default values ββto ignore them, if the field was not filled, I could get the real value in the "Values ββto be ignored" mix.
FYI, I cannot manually enter the values, since the form is dynamic and cannot directly query the database, because it is a Wordpress website.
source share