Closed Parakleta closed 8 years ago
I need to amend this suggestion to use the test valid && this.value && this.hasValidator()
since the validate()
function has no knowledge of the required field and so should never be passed an empty value.
jsbin with the repro steps: http://jsbin.com/zayate/edit?html,output
Fixed in #23
The
validate()
function bails out early if the input value is empty and the input is not required. Browsers set the value to empty if the input doesn't pass type validation for the input field, and then setvalidity.valid
to say that the input was invalid. The iron-input validate function should give priority to thevalidity.valid
field being false above all else, and then only check the custom validator (thevalidity.valid
field already checks the required attribute).That is, if the browser says the input doesn't match the type of the field then it is automatically invalid regardless of any other processing that may happen. The custom validator is only applied to further restrict the input if the browser thinks it is valid.
I propose something like:
I don't know anything about cross browser compatibility so there may be problems with this approach, but the current approach prevents me from detecting and handling validation errors on numeric input fields.