You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just discovered accidentally that HTML::Form::TextInput scrapes the value of its associated <label> tag and stores it in a hash entry for "value_name".
use HTML::Form;
use Data::Dumper;
$Data::Dumper::Indent = $Data::Dumper::Terse = $Data::Dumper::Sortkeys = 1;
my ($form) = HTML::Form->parse( <<'HTML', 'https://example.com' );
<form> <labelfor="id-cpw">Current Password</label> <inputid="id-cpw"name="curr_password"value=""type="password"><!-- input is before label here. --> <inputid="id-npw"name="new_password"value=""type="password"disabled="disabled"> <labelfor="id-npw">New Password</label></form>HTMLformy$name ( qw( curr_password new_password ) ) {
my$input = $form->find_input( "$name" );
print Dumper( $input);
}
Unfortunately there's no documented method on the object to access that. Also, note that the field is not populated unless the <label> comes before the <input>, even though that's not a requirement in HTML. (It's the order that causes this, not that the 2nd field in this example is disabled)
It would be great if there was a documented method that would let the user get at the <label> tag value for any input field: Text, password, checkbox, radio. It would make it super easy to validate that all fields on a form had proper <label>s, which are one of the lowest of low-hanging fruit for making web forms more accessible.
The text was updated successfully, but these errors were encountered:
I just discovered accidentally that HTML::Form::TextInput scrapes the value of its associated
<label>
tag and stores it in a hash entry for "value_name".gives this output:
Unfortunately there's no documented method on the object to access that. Also, note that the field is not populated unless the
<label>
comes before the<input>
, even though that's not a requirement in HTML. (It's the order that causes this, not that the 2nd field in this example is disabled)It would be great if there was a documented method that would let the user get at the
<label>
tag value for any input field: Text, password, checkbox, radio. It would make it super easy to validate that all fields on a form had proper<label>
s, which are one of the lowest of low-hanging fruit for making web forms more accessible.The text was updated successfully, but these errors were encountered: