Effect:
Input
TEXTAREA: Limited to 100 words
Source:
Input<InputName= "TextField"Type= "Text"MaxLength= "20"Value= "Please enter text ..."onfocus= "if (value = =" Please enter text: ') {value = '} 'Onblur= "if (value = =") {value= ' Please enter text: '} '/><Br><Br>TextArea<TextAreaCols= "50"Rows= "5"Id= "TEXTAREA"OnKeyDown= "Textdown (event)"OnKeyUp= "Textup ()"onfocus= "if (value== ' limit 100 words ') {value= '}"Onblur= "if (value = =") {value= ' limited to 100 words '} "> Limited to 100 words</TextArea><SCRIPTType= "Text/javascript">functionTextdown (e) {textevent=EIf(Textevent.keycode==8) {Return; }If(document.getElementById (‘TextArea‘). Value.length>=100) {alert ("Hero, mercy, here limit word 100")If(!document.all) {Textevent.preventdefault ();}Else{Textevent.returnvalue=False; } }}functionTextup () {VarS=document.getElementById (‘TextArea ' ). Value; // Determines whether the number of text areas with ID text exceeds 100 (s.length > 100< Span style= "color: #000000;" ) {document.getElementById ( textarea ' ). Value =0 100< Span style= "color: #000000;" >); }}</script>
Http://www.cnblogs.com/ljmin/archive/2012/07/19/2600170.html
Inupt textarea hint text (click to disappear, do not enter recovery) and limit the number of words