Javascript code for validating textarea


The option of using pure HTML, sometimes with a touch of CSS, to complement Java Script form validation was until recently unthinkable.Sure there have been all kinds of whacky plug-ins over the years aimed at achieving this, but never a single standard that we could work towards.For a more detailed introduction to HTML5 form validation you can find some great articles linked under References below.In this article we intend to present only a number of simple examples to get you started, covering the basic form elements.Before you ask, and someone always does, these examples will currently work in the following browsers: Safari 5, Chrome 6, Opera 9, Firefox 4 Beta and the i Phone/i Pad.Also each browser has a slightly different default behaviour.The simplest change you can make to your forms is to mark a text input field as 'required': This informs the (HTML5-aware) web browser that the field is to be considered mandatory.Different browsers may mark the input box in some way (Firefox 4 Beta adds a red box-shadow by default), display a warning (Opera) or even prevent the form from being submitted if this field has no value.



Obviously neither example is very limiting, but it will prevent people from entering completely wrong values, such as phone number, strings with multiple '@'s or spaces.

Here is how it appears in Safari (with our CSS formatting to show the (in)valid state): In a similar fashion to the Again, the input box appears as normal: This time the minimum requirement for most browsers is one or more letters followed by a colon. :[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f] | \\[\x01-\x09\x0b\x0c\x0e-\x7f]) ) \])\z Or you can look here for more solutions.