界面的东西

 

弹出框:response.getWriter().print(
      "<script>alert('添加成功');location.href='"
        + request.getContextPath()
        + "/sale.do?o=toList'</script>");

 

 

-----------------------------------------------

验证:  function doSubmit(o){
     if(chanceSource()&&chanceName()&&chanceRate()&&chanceTitle()&&chanceLinkman()&&chanceTel()&&chanceDesc()){
      document.forms[0].action="sale.do?o="+o;
     document.forms[0].submit();
     }
   }
   
   function chanceSource(){
    var chanceSource=document.getElementById("item.chcSource").value;
    
    var patrn=/^(?:[\u4e00-\u9fa5]*\w*\s*)+$/;
    var source=trim(chanceSource);
    if(source!=""){  
     if (!patrn.exec(source))
     {
      document.getElementById("chanceSource").innerHTML="不能输入特殊字符";
      return  false;
     }
    }
    document.getElementById("chanceSource").innerHTML="";
    return true;
   }
   
   function chanceName(){
    var chanceName=document.getElementById("item.chcCustName").value;
    var name=trim(chanceName);
    var patrn=/^(?:[\u4e00-\u9fa5]*\w*\s*)+$/;
    if(name!="" ){  
     if (!patrn.exec(name))
     {
      document.getElementById("chanceName").innerHTML="*不能输入特殊字符";
      return  false;
     }
    }else{
     
     document.getElementById("chanceName").innerHTML="*不能为空";
     return  false;
    
    }
    document.getElementById("chanceName").innerHTML="";
    return true;
   }
   
     function  chanceRate(){
    var chanceRate=document.getElementById("item.chcRate");
    var patrn=/^[0-9]+$/;
   
    if(chanceRate.value!=""){  
     if (!patrn.exec(chanceRate.value))
     {
      document.getElementById("chanceRate").innerHTML="*请输入正整数";
      return  false;
     }
     if(chanceRate.value<1||chanceRate.value>100){
      document.getElementById("chanceRate").innerHTML="*大于等于1小于等于100";
      return  false;
     }
    }else{
     document.getElementById("chanceRate").innerHTML="*不能为空";
     return  false;
    }
    document.getElementById("chanceRate").innerHTML="";
    return true;
   }
   
   function chanceTitle(){
    var chanceTitle=document.getElementById("item.chcTitle").value;
    var patrn=/^(?:[\u4e00-\u9fa5]*\w*\s*)+$/;
    var title=trim(chanceTitle);
    if(title!=""){  
     if (!patrn.exec(title))
     {
      document.getElementById("chanceTitle").innerHTML="*不能输入特殊字符";
      return  false;
     }
    }else{
     document.getElementById("chanceTitle").innerHTML="*不能为空";
     return  false;
    }
    document.getElementById("chanceTitle").innerHTML="";
    return true;
   }
   
   function chanceLinkman(){
    var chanceLinkman=document.getElementById("item.chcLinkman").value;
    var patrn=/^(?:[\u4e00-\u9fa5]*\w*\s*)+$/;
    var linkman=trim(chanceLinkman);
    if(linkman!=""){  
     if (!patrn.exec(linkman))
     {
      document.getElementById("chanceLinkman").innerHTML="不能输入特殊字符";
      return  false;
     }
    }
    document.getElementById("chanceLinkman").innerHTML="";
    return true;
   }
   
   
  
   function chanceTel(){
   var tel=document.getElementById("item.chcTel").value;//联系人电话
   //验证电话号码(手机或者座机)
   if(!checkPhone(tel) && tel.length!=0 && tel!=""&&!checkTel(tel))
   {
    document.getElementById("chanceTel").innerHTML="电话号码格式不正确";
    return false;
   }
   document.getElementById("chanceTel").innerHTML="";
   return true;
  }
  
  //验证手机号码是否合法
  function checkPhone(value){
   var telPhone=new RegExp(/^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/); //所有手机号
   if(telPhone.test(value)){
    return true;
   }else{
    return false;
   }
  }
  //验证座机是否合法
  function checkTel(value){
   var tel=new RegExp(/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/);
   if(tel.test(value)){
    return true;
   }else{
    return false;
   }
  }
   
   function chanceDesc(){
    var chanceDesc=document.getElementById("item.chcDesc").value;
    var patrn=/^(?:[\u4e00-\u9fa5]*\w*\s*)+$/;
    var desc=trim(chanceDesc);
    if(desc!=""){  
     if (!patrn.exec(desc))
     {
      document.getElementById("chanceDesc").innerHTML="*不能输入特殊字符";
      return  false;
     }
    }else{
     document.getElementById("chanceDesc").innerHTML="*不能为空";
     return  false;
    }
    document.getElementById("chanceDesc").innerHTML="";
    return true;
   }
   //去掉字符串两端的空格
   function trim(str)
   {
    return str.replace(/(^\s*)|(\s*$)/g, "");
   }
   //设置字符长度
  function maxlength(Control,Length)
       
          {
            var num = Control.value.length;
        
            if(window.event.keyCode==229)
            {
                 num = Control.value.length;
                 Control.value=Control.value.substring(0,Length);
            }
            if(num>Length)
            {
              Control.value=Control.value.substring(0,Length);
            }
             return true;
        }
   
   function helps(){
   alert('抱歉!暂无帮助');
   }

 

--------------------------------------------

===========================================

------鼠标放上去现实多少个字

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<samp title="${saleUp.chcDesc}"> ${fn:substring(saleUp.chcDesc,0,30)}</samp><font color="#ff0101">(如果机会描述多于30个字,请把鼠标放在字上查看更多信息)</font>

 

 

============================================================

字符编码转换:String plaTodo = new String(request.getParameter("plane.plaTodo")
     .getBytes("ISO-8859-1"), "GBK");

 

--------------------------------------------

去空格急确定是否删除

: function doStopPlan(chanceId){
   if(window.confirm("你确定要终止开发?")){
    this.to("sale.do?o=doStop&chanceId="+chanceId)
   }
  }
   //去掉字符串两端的空格
   function trim(str)
   {
    return str.replace(/(^\s*)|(\s*$)/g, "");
   }

 -----------------------------------------------

<c:if test="${requestScope.list==null}">
<jsp:forward page="pingpang.do?o=findLists"></jsp:forward>

</c:if>

 

 

 

 

 

 

你可能感兴趣的:(jsp,String,function,null,手机,电话)