Getting value of form element with .value is empty using .submit() #46

liamgooding opened this Issue Aug 15, 2011 · 5 comments


None yet
2 participants

using the .submit() listener for a form

    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

filmaj commented Aug 29, 2011

Can you post the markup, or show full code for a test? What kind of element is it with id "input-id"?


ghost commented Sep 1, 2011

I can confirm this issue, but I only tested this on the Android emulator.

x$("#buttont").click(function (element) {

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.


filmaj commented Sep 1, 2011

Thank you, I'll check this out as soon as I get a chance


ghost commented Oct 28, 2011

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 
<                 if (el.tagName == 'input' && attribute == 'value') el.value = val;
>                 if (el.tagName.toLowerCase() == 'input' && attribute == 'value') el.value = val;
<                 if (el.tagName == 'input' && attribute == 'value') attrs.push(el.value);
>                 if (el.tagName.toLowerCase() == 'input' && attribute == 'value') attrs.push(el.value);

filmaj commented Oct 28, 2011

Now fixed in 1f2cdda - also added specs for this. Thanks guys!

filmaj closed this Oct 28, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment