2010-02-24 6 views

답변

2

아마도 JS 유효성 검사를 사용할 수 있습니다.

JSP :

<s:checkbox id="other" name="other" /> 
<s:textfield id="otherDetails" name="otherDetails"></s:textfield> 

<sx:submit 
      id="button_submit" 
      name="button_submit" 
      onclick="return checkOther();" /> 

JS는 :

function checkOther() { 
    if(document.getElementById('other').checked == true) { 
     if(document.getElementyById('otherDetails').value.length == 0) { 
      //you should trim the value 
      alert("Insert other details"); 
      return false; 
     } 
    } 

    return true; 
} 
+0

'

+0

아니, 오타가 아니라 Strutses Dojo 태그입니다. struts 유효성 검사를 위해 당신은 asnwer를 얻을 수 있기를 바랍니다. – Trick

4

당신은 아마 표현 유효성 검사기를 사용할 수 있습니다.

<validators> 

    <validator type="expression"> 
    <param name="expression">(other && (otherDetails!=null && otherDetails.trim()!=""))</param> 
    <message>You must provide other details.</message> 
    </validator> 

</validators> 

더 많은 정보를 원하시면 http://struts.apache.org/2.2.1/docs/validation.html를 참조하십시오 : 당신은 XML을 통해 검증하는 경우, 당신은 뭔가를해야한다.

관련 문제