Code detection textarea fill in the length, not filled out prompts need to be filled out, less than 15 characters when the hint needs longer than 15 characters, when successful display the suggestions filled out.
<script type= "Text/javascript" >
//jquery code
function confirm ()
{
if ($ ("#advice"). Val (). Length = = 0)
{
alert ("We can ' t your advice.") Maybe You should fill the "form");
$ ("#advice"). focus ();
return false;
}
else if ($ ("#advice"). Val (). length <=
{
alert ("Your advice should longer than.");
$ ("#advice"). focus ();
return false;
}
else
{
alert ("Thank for your advice! You'll get out reply the hours for advice:\n "+$ (" #advice "). Val ());
return true;
}
</script>
<form action= "method=" POST "onsubmit=" return confirm (); ">
<textarea id=" advice "Rows=" "cols=" placeholder= "give us some advice?" ></textarea>
<input type= "Submit" value= "Thank You"/>
</form>
> Key points
1. There must be a onsubmit= "return confirm ()" and "return" is an indispensable word.
2. Self-complete Web page structure.
The above mentioned is the entire content of this article, I hope you can enjoy.