Search code examples
javascriptjqueryplaceholderwebshim

Placeholder text is returned when using value property of input text box in form


I am using webshim to provide the html5 placeholder functionality in my textboxes in IE8.

This works fine when I submit the form - the field is blank if the user has not entered anything.

But when I tried to jazz things up by making an ajax request hooked to an onclick event the following line of code returns the placeholder text instead of an empty string.

document.getElementById('idOfTextBox').value

How can I avoid this behavior?


Solution

  • V31, that was super quick! You are correct, jquery gets it right.

    $('#idOfTextBox').val() 
    

    gives the correct result