Getting value of form element with .value is empty using .submit()
liamgooding opened this issue · comments
using the .submit() listener for a form
x$('#form-id').submit(function(){
console.log(document.getElementById('input-id').value); // correctly gets value
console.log(x$('#input-id').attr('value')); // gives undefined
console.log(x$('#input-id').value); // gives undefined
});
Can you post the markup, or show full code for a test? What kind of element is it with id "input-id"?
I can confirm this issue, but I only tested this on the Android emulator.
Javascript:
x$("#buttont").click(function (element) {
alert(x$("#p").attr("value"));
});
Html 1:
<input type="password" id="p" name="p" />
Html 2:
<input type="password" id="p" name="p" value="test" />
When run with "Html 1", always returns an empty string (""). When run with "Html 2", always returns "test", no matter if the values in the field has changed.
Thank you, I'll check this out as soon as I get a chance
I get this problem on mobile safari and chrome because the "tagName" of the element returned by x$('#button') is "INPUT" and not what the code is == to "input".
$ diff xui-2.2.0.js xui-2.2.0-mod.js
555c555
< if (el.tagName == 'input' && attribute == 'value') el.value = val;
---
> if (el.tagName.toLowerCase() == 'input' && attribute == 'value') el.value = val;
564c564
< if (el.tagName == 'input' && attribute == 'value') attrs.push(el.value);
---
> if (el.tagName.toLowerCase() == 'input' && attribute == 'value') attrs.push(el.value);