大家好,我有以下代码,我需要在javascript中添加onfocus函数,而不是在textarea标签中添加它,因为如果我在textarea标签中添加它是不安全的
同样使js代码按textarea类工作(class =" limittext")
Vue.set(self.books, i, {
'title': item.title
});
答案 0 :(得分:0)
您可以使用data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/7QCcUGhvdG9zaG9w....
在javascript中添加事件侦听器,并使用SELECT
d.empid
, d.empname
, d.department
, d.designation
, d.totalleaves
, d.totalcompoff
, SUM(d.totalleaves + d.totalcompoff) AS remainingleaves
FROM (
SELECT
a.empid
, a.empname
, a.department
, a.designation
, a.totalleaves
, COUNT(b.empname) AS totalcompoff
FROM employeedetails a
LEFT OUTER JOIN compoff b ON a.empname = b.empname
GROUP BY
a.empid
, a.empname
, a.department
, a.designation
, a.totalleaves
) d
GROUP BY
d.empid
, d.empname
, d.department
, d.designation
, d.totalleaves
, d.totalcompoff
获取类“limittext”的所有元素。你可以做的是找到感兴趣的类的所有元素,然后遍历它们并为每个元素设置一个事件监听器。这样的事情应该有效:
.addEventListener()
答案 1 :(得分:0)
我不知道这是否是最好的解决方案。我没能让它按类工作,但我能够通过使用ID使代码工作并在js代码上做一些版本
感谢所有人试图帮助我
https://jsfiddle.net/zf155z9y/3/
<html>
<head>
<title>Limit Textarea</title>
<style type="text/css">
textarea{
width:400px;
height:200px
}
</style>
<script language="vbscript" type="text/vbs">
set_ie_alert()
Function vb_alert(msg_str)
MsgBox msg_str,vbOKOnly+vbInformation+vbApplicationModal,alert_title
End Function
</script>
</head>
<body>
<textarea id="myForm" wrap="off">some text</textarea>
<script type="text/javascript">
var alert_title='Input Restriction';
var x = document.getElementById('myForm');
x.addEventListener("focusin", limitTextarea);
function limitTextarea(){
var el = this;
var maxLines = 5;
var maxChar = 0;
if(!el.x){
el.x=uniqueInt();
el.onblur=function(){clearInterval(window['int'+el.x])}
}
window['int'+el.x]=setInterval(function(){
var lines=el.value.replace(/\r/g,'').split('\n'),
i=lines.length,
lines_removed,
char_removed;
if(maxLines&&i>maxLines){
alert('You can not enter\nmore than '+maxLines+' lines');
lines=lines.slice(0,maxLines);
lines_removed=1
}
if(maxChar){
i=lines.length;
while(i-->0)if(lines[i].length>maxChar){
lines[i]=lines[i].slice(0,maxChar);
char_removed=1
}
if(char_removed)alert('You can not enter more\nthan '+maxChar+' characters per line')
}
if(char_removed||lines_removed)el.value=lines.join('\n')
},50);
}
function uniqueInt(){
var num,maxNum=100000;
if(!uniqueInt.a||maxNum<=uniqueInt.a.length)uniqueInt.a=[];
do num=Math.ceil(Math.random()*maxNum);
while(uniqueInt.a.hasMember(num))
uniqueInt.a[uniqueInt.a.length]=num;
return num
}
Array.prototype.hasMember=function(testItem){
var i=this.length;
while(i-->0)if(testItem==this[i])return 1;
return 0
};
function set_ie_alert(){
window.alert=function(msg_str){
vb_alert(msg_str)
}
}
</script>
</body>
</html>