Struts中验证validator
一般的方法是直接将error写到页面上,但是如果想告诉客户哪个地方出错,要将出错地方的颜色改变,请问是否可行?能不能提供代码?
各位大虾,请多帮助啊!!
在线等待中,请指教...........
多谢了!!!

解决方案 »

  1.   

    可以,用css,error时设定成你需要的颜色
      

  2.   

    这是可以的,你只需要将error标签放每一个文本框的后面(即每一个文本区后都有一个错误提示标签)。而且可以通过<font/>标签来改变提示内容的颜色。
      

  3.   

    shan1119(大天使,卐~解!) :
    你的方法能否实现只改变对应位置的背景色?还是将页面所有项目的背景色都改变呢?
    是否可以提供参考代码?
    多谢了!
      

  4.   

    error或者message的对应标签里可以解决你的问题
      

  5.   

    就设置error的css属性就可以了,只有出错的时候这个error标签才会出来。
      

  6.   

    error的css属性?----->能不能讲明白一些?
      

  7.   

    就设置error的css属性就可以了,只有出错的时候这个error标签才会出来。
    ----><html:errors>中只有name,property,bundle属性不是吗
      

  8.   


    可以变相的实现啊。
    <span style="color: #999999; background-color:#FF0000"><html:errors property="term"/></span><div style="color: #999999; background-color:#FF0000"><html:errors property="term"/></div>
    你试一下看。。
      

  9.   

    ================================================================================
    <html:errors property="username"/>
    <html:errors property="password"/>
    --------------------------------------------------------------------------------
    <table cellspacing="0" cellpadding="1" border="0">
      <tr>
        <td><input type="text" name="username" size="15" maxlength="8" value="" autocomplete="off"/></td>
      </tr>
      <tr>
        <td><input type="password" name="password" size="15" maxlength="16" value="" autocomplete="off"/></td>
      </tr>
    </table>
    ================================================================================象上面一样,如果我要:
    1)错误验证信息在页面最上头集中显示
    2)对应于错误验证信息,页面对应的项目背景色改变
    该如何解决呢?请指教......
      

  10.   

    那你还不如就在每一个文本框后面加一个<font color="red"><html:errors/></font>
    当出现错误的时候就会在相应的文本框后面提示错误信息。这也是strtus固有格式
      

  11.   

    YOYOOOP() :
    那你还不如就在每一个文本框后面加一个<font color="red"><html:errors/></font>
    当出现错误的时候就会在相应的文本框后面提示错误信息。这也是strtus固有格式
                             ||
                             \/
    我也想这么做,但是画面的项目很多很紧凑的话,直接在文本框后显示错误信息就显得太乱了,
    何况,客户也决定要将验证信息集中显示,大家还有什么好的解决办法没有?救命啊.........
      

  12.   

    Ajax 让你的用户体验到新的感觉。
      

  13.   

    YOYOOOP() Ajax 让你的用户体验到新的感觉。--->
    扯哪呢,火烧眉毛了,开发模式不是说换就能换的,给我提议个好方法比较实在.....help...
      

  14.   

    LZ不知道 <html:errors property=""/>怎么使用吗?加在INPUT后面
      

  15.   

    ================================================================================
    <html:errors property="username"/>
    <html:errors property="password"/>
    --------------------------------------------------------------------------------
    <table cellspacing="0" cellpadding="1" border="0">
      <tr>
        <td><input type="text" name="username" size="15" maxlength="8" value="" autocomplete="off"/></td>
      </tr>
      <tr>
        <td><input type="password" name="password" size="15" maxlength="16" value="" autocomplete="off"/></td>
      </tr>
    </table>
    ================================================================================象上面一样,如果我要:
    1)错误验证信息在页面最上头集中显示
    2)对应于错误验证信息,页面对应的项目背景色改变
    该如何解决呢?请指教......
      

  16.   

    <logic:messagesPresent>
      <textarea name="textareaError"  cols="60" rows="4" class="textareaError" readonly ><html:errors /></textarea>
    </logic:messagesPresent>这样就把所有的错误信息都写在textarea中<% String bgcolor = ""; %>
    <logic:messagesPresent property="username">
        <% stylerror = "yellow"; %>
    </logic:messagesPresent>
    <td><input type="text" name="username" size="15" maxlength="8" value="" autocomplete="off" bgcolor="<%=bgcolor%>"/></td>
      

  17.   

    var errBgColor = "yellow"var errmsg01='';
    <html:messages id='msg' message='false'>
    errmsg01 = errmsg01 + "<bean:write name='msg' />" + "<BR>"
    </html:messages>
    if (errmsg01!='') {
        outmsg(errmsg01);
    <%
        Iterator errProp = ((ActionMessages)request.getAttribute(Globals.ERROR_KEY)).properties();
        while(errProp.hasNext()){ 
    %>
         ChangeBackGroundColor("<%=errProp.next()%>", errBgColor)
    <%  }  %>
    }通过这个方法把所有出错的项目都改变被景色
      

  18.   

    form.username.style.backgroundColor="red";
    form.password.style.backgroundColor="red";在你验证到错误的js中加入上面的代码就可以了
      

  19.   

    cender(cender) 
    ---------------------------------------------------------------
    var errBgColor = "yellow"var errmsg01='';
    <html:messages id='msg' message='false'>
    errmsg01 = errmsg01 + "<bean:write name='msg' />" + "<BR>"
    </html:messages>
    if (errmsg01!='') {
        outmsg(errmsg01);
    <%
        Iterator errProp = ((ActionMessages)request.getAttribute(Globals.ERROR_KEY)).properties();
        while(errProp.hasNext()){ 
    %>
         ChangeBackGroundColor("<%=errProp.next()%>", errBgColor)
    <%  }  %>
    }这种方法的试了,没有成功......请教...能给详细点的吗?
      

  20.   

    .errorMessage{
    color:red;
    }
      

  21.   

    能提供代码吗,谢谢!!!!!刷新之后,画面还没有载入如何设置页面对象的背景色,并且如何知道是哪个Form里面的对象出错?