2010-11-16 4 views

Répondre

1

oui, vous pouvez définir infobulle zone de texte

/* 
txtname id of youe textbox 
val is value of textbox 
ccount is max length of textbox. 
if ccount is set to 4 then 
if value of textbox exceed then 4 then it will show tooltip 
*/ 
function txtToolTip(txtname, val, ccount) { 
    var txtTool = document.getElementById(txtname); 
    if (txtTool.value.length > ccount) { 
     //Setting tool tip value. 
     txtTool.title = txtTool.value; 
    } 
} 

votre boîte d'entrée est

<input type="text" name="txtnm" id="txtnm" onkeyup="txtToolTip(this.id, this.value, 4);"/> 
+0

Merci beaucoup .... Cela a fonctionné .... – apoorvabade

+0

Peut-il être montré fixe ??? Je veux dire que l'info-bulle apparaît maintenant quand je déplace le curseur sur cette zone de texte ?? Existe-t-il un moyen par lequel je continue à montrer l'info-bulle jusqu'à ce que le caractère requis soit effacé? – apoorvabade

0

Vous pouvez utiliser mon code pour résoudre votre problème:

<!doctype html> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
 
<head> 
 
    <title>Input Key Filter Test</title> 
 
\t <meta name="author" content="Andrej Hristoliubov [email protected]"> 
 
\t <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
 
\t 
 
\t <!-- For compatibility of IE browser with audio element in the beep() function. 
 
\t https://www.modern.ie/en-us/performance/how-to-use-x-ua-compatible --> 
 
\t <meta http-equiv="X-UA-Compatible" content="IE=9"/> 
 
\t 
 
\t <link rel="stylesheet" href="https://rawgit.com/anhr/InputKeyFilter/master/InputKeyFilter.css" type="text/css"> \t \t 
 
\t <script type="text/javascript" src="https://rawgit.com/anhr/InputKeyFilter/master/Common.js"></script> 
 
\t <script type="text/javascript" src="https://rawgit.com/anhr/InputKeyFilter/master/InputKeyFilter.js"></script> 
 
\t 
 
</head> 
 
<body> 
 
\t <h1>Text field. String length is limited to 10 sumbols</h1> 
 
    Max Length input field: 
 
    <input type='text' id='maxLength' maxlength ="11" /> 
 
    New string: <span id="newString"></span> 
 
    <script> 
 
     CreateMaxLengthFilter('maxLength', { 
 
      formatMessage: 'Length limit to %s sumbols' 
 
      , onerror: function (elementInput) { 
 
       elementInput.focus();//except Firefox 
 
      } 
 
      , onblur: function (event) { 
 
       document.getElementById('newString').innerHTML = event.target.value; 
 
      } 
 
     }); 
 
    </script> 
 

 
</body> 
 
</html>