When I use textarea.checkValidity() or textarea.validity.valid in javascript with an invalid value both of those always return true, what am I doing wrong?
<textarea name="test" pattern="[a-z]{1,30}(,[a-z]{1,30})*" id="test"></textarea> jQuery('#test').on('keyup', function() { jQuery(this).parent().append('<p>' + this.checkValidity() + ' ' + this.validity.patternMismatch + '</p>'); });
http://jsfiddle.net/Riesling/jbtRU/9/
HTML5 <textarea> element does not support the pattern attribute.
If you use prepare statements then you will not need real_escape_string at all. For validating ANY field you need to consider what it is allowed to contain and either remove anything that is invalid or reject the field if it contains anything invalid. it is not working.
From the MDN documentation: " <textarea> does not support the value attribute".
The validation process evaluates whether the input value is in the correct format before submitting it. For example, if we have an input field for an email address, the value must certainly contain a valid email address; it should start with a letter or a number, followed by the @ symbol, then end with a domain name.
HTML5 <textarea>
element does not support the pattern
attribute.
See the MDN doc for allowed <textarea>
attributes.
You may need to define this functionality yourself.
Or follow the traditional HTML 4 practice of defining a JavaScript/jQuery function to do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With