文本框字符限制在69个以内——Bigcommerce后台添加产品

来源:互联网 发布:mysql 行列转换函数 编辑:程序博客网 时间:2024/06/13 06:35

Bigcommerce后台添加产品时,他的标题限制在69个字符内。但这个系统本身没有计数的功能,每次Copy一个产品标题时,都要在Word里面计算好个数是在69个以内,才能输入到后台,十分麻烦。以下针对这个问题制作了一个小插件:

 

脚本:

<SCRIPT LANGUAGE="JavaScript"> 
<!--// 
function textCounter(field, countfield, maxlimit) {

//无法输入
//if (field.value.length > maxlimit)  
//field.value = field.value.substring(0, maxlimit); 
//else   
//countfield.value = maxlimit - field.value.length; 


countfield.value =  field.value.length; 

 } 
//--> 
</SCRIPT>

 

页面:

<form enctype="multipart/form-data" action="index.php?ToDo={{ FormAction|raw }}" id="frmProduct" method="post">

<input type="text" id="prodName" name="prodName" class="Field400" value="{{ ProdName|raw }}" onKeyDown="textCounter(document.getElementById('frmProduct').prodName,document.getElementById('frmProduct').remLen,69);" onKeyUp="textCounter(document.getElementById('frmProduct').prodName,document.getElementById('frmProduct').remLen,69);">&nbsp;You can enter<input class="tlength" name="remLen" type="text" value="69" readonly="readonly">characters


</form>

 

添加样式:

.tlength{font-size:12px;color:#f00000;width:25px;border:none;padding:0 0 0 5px;background:#f9f9f9;}