Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: If single radio button selected,validate single field else select double field

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default If single radio button selected,validate single field else select double field

    <jsp:useBean id="chequeBean" scope="session" class="my.com.infopro.ibank.ui.bean.ChequeBean"/>
    <jsp:useBean id="labelBean" scope="session" class="my.com.infopro.ibank.ui.bean.LabelBean"/>
    <jsp:useBean id="lang" scope="session"[CODE][CODE][/CODE][/CODE]
    	class="my.com.infopro.ibank.ui.bean.LanguageBean" />
     
    <%@ page language="java" import = "java.util.*" errorPage="" %>
    <%@ page import="my.com.infopro.ibank.ui.dto.ChequeDto"%>
    <%@ page import="my.com.infopro.ibank.ui.bean.ChequeBean"%>
    <%
    	String contextPath = request.getContextPath();
        chequeBean.queryAccList();
     
    %>
    <html>
     
    <head>
    <title><%=labelBean.getLabel("STOP_CHEQUE")%></title>
    <meta HTTP-EQUIV="Pragma" content="no-cache"> 
    <meta HTTP-EQUIV="Expires" content="-1"> 
    <link href="<%=contextPath%>/scripts/style.css" rel="stylesheet" type="text/css">
    <script language="JavaScript" src="<%=contextPath%>/scripts/date-picker.js"></script> 
    <script language="JavaScript" src="<%=contextPath%>/scripts/checkDate.js"></script> 
    <script language="JavaScript" src="<%=contextPath%>/scripts/EntryValidation.js"/></script>
    <script language="JavaScript">
     
    function validateAndSubmit() {
     
     
    	var msg1 = "<%=labelBean.getLabel("MSG_REQUIRED_FIELD")%>";
    	var msg2 = "<%=labelBean.getLabel("MSG_CANNOT_CONTAIN_CHARACTER")%>";
    	var msg3 = "<%=labelBean.getLabel("MSG_IN_THE_FIELD")%>";
    	var msg4 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER")%>";
    	var msg5 = "<%=labelBean.getLabel("WITH")%>";
    	var msg6 = "<%=labelBean.getLabel("TO")%>";
    	var msg7 = "<%=labelBean.getLabel("MSG_CHARACTER")%>";
    	var msg8 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER_VALID_NUMBER")%>";
    	var msg9 = "<%=labelBean.getLabel("MSG_REQUIRED_FIELD")%>";
    	var msg10 = "<%=labelBean.getLabel("MSG_WITH_EXACTLY")%>";
    	var msg11 = "<%=labelBean.getLabel("MSG_WITH_VALID_DATE")%>";
    	var msg12 = "<%=labelBean.getLabel("MSG_EXAMPLE_DATE")%>";
    	var msgNum11 = "<%=labelBean.getLabel("MSG_WITH_A_MINIMUM_VALUE_OF")%>";
    	var msgNum12 = "<%=labelBean.getLabel("MSG_WITH_A_MAX_VALUE_OF")%>";
    	var msgNum13 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER_ROUND_INETEGER")%>";
    	var msgNum14 = "<%=labelBean.getLabel("MSG_PLEASE_ENTER_AT_MOST")%>";
    	var msgNum15 = "<%=labelBean.getLabel("MSG_DECIMAL_PLACES")%>";
    	var msgEnter = "<%=labelBean.getLabel("MSG_PLEASE_ENTER_VALID")%>";
    	var errorMsg = "<%=labelBean.getLabel("MSG_LOWECASE_ALPHABET_ALLOWED")%>"
     
    	 if (status()==true){ 
    		 <%System.out.println("show");%>     	
    	  	if (! validateTextEntry(form.chqNum, "<%=labelBean.getLabel("CHQNUM")%>" + " ",true,1,20, msg1, msg2, msg3, 
    	  			msg4, msg5, msg6, msg7, msg10) )
    	        return false;
    	 } 
    	 else if (status()==false){
    		 <%System.out.println("hide");%>  
    	  	if (! validateTextEntry(form.chqNumFrom, "<%=labelBean.getLabel("CHQNUMFROM")%>" + " ",true,1,20, msg1, msg2, msg3,
    	  			msg4, msg5, msg6, msg7, msg10) )
    	        return false;
     
    	  	if (! validateTextEntry(form.chqNumTo, "<%=labelBean.getLabel("CHQNUMTO")%>" + " ", true,1,20, msg1, msg2, msg3,
    	  			msg4, msg5, msg6, msg7, msg10) )
    	        return false;	  	
    	 }
     
     
     
    	    return true;
    	}
     
     
    function status(sta){
    	if(sta==true){
    		status=true;
    	}
    	else
    		status=false;
     
    	return status;
     
     
     
    }
     
     
     
    function show(id)  
    {  
         if (document.getElementById(id).style.display == 'none')  
         {  
              document.getElementById(id).style.display = 'block';
              status(true);
     
     
         } 
     
    }  
    //-->  
     
    <!--  
    function hide(id)  
    {  
              document.getElementById(id).style.display = 'none'; 
              status(false);
     
    } 
     
    </script>
    </head>
     
    <body>
    <form name="form" method="POST" action="<%=contextPath%>/ChequeServlet?tranx=confirm" dir="<%=lang.getDir()%>">
    <jsp:include page="/Header.jsp"/>
      <table width="500" align="center">
        <tr> 
          <td align="left" colspan="3">&nbsp;</td>
        </tr>
        <tr> 
          <td align="left" colspan="3" class="mainHeader"><%=labelBean.getLabel("STOP_CHEQUE")%></td>
        </tr>
    	<tr>
    	<td colspan="3">&nbsp;</td>
    	</tr>
    	<tr>
    	<td colspan="3" class="subHeader"><%=labelBean.getLabel("CHQ_DETAIL") %></td>
    	</tr>
     
    	</table><br />
    	<table width="500" align="center">
        <tr> 
          <td class="lbl"><span class="requiredFieldIndicator">* </span><%=labelBean.getLabel("ACC_NUMBER")%></td>
          <td width="10"  class="lbl">:</td>
          <td width="305" align="left">  
          <select size="1" name="accNum">
     
    	 <%
    	  		for (Iterator iter = chequeBean.getAccList().iterator(); iter.hasNext();) {
    	  			 ChequeDto chqDto = (ChequeDto)iter.next();	
     
    	  %>
    	 <option value="<%=chqDto.getAccNum()%>"><%=chqDto.getAccNum()%></option>
    	  <%  } %>
    	  </select>
    	  </td>
        </tr>
     
        <tr>		
    		<td align="right">
    			<input type="radio" class="radioStyle" name="radio" value="1" onfocus="show('single');hide('multiple');hide('multiple1');return true;" checked="checked">
    			<%=labelBean.getLabel("STOP_SINGLE")%>
    		</td>
    		<td>&nbsp;</td>
    		<td>
    			<input type="radio" class="radioStyle" name="radio" value="2" onfocus="hide('single');show('multiple');show('multiple1');return true;">
    			<%=labelBean.getLabel("STOP_MULTIPLE")%>
    		</td>
    	</tr>
     
        <tr id="single"> 
          <td class="lbl"><span class="requiredFieldIndicator">* </span><%=labelBean.getLabel("CHEQUE_NUMBER")%></td>
          <td  class="lbl"width="10">:</td>
          <td colspan="2" align="left"> 
          <input name="chqNum" type="text" size="15"> 
    	  </td></tr>
     
    	 <tr id="multiple" style="display: 'none'"> 
          <td class="lbl"><span class="requiredFieldIndicator">* </span><%=labelBean.getLabel("FROM_CHEQUE_NUMBER")%></td>
          <td  class="lbl"width="10">:</td>
          <td colspan="2" align="left"> 
            <input name="chqNumFrom" type="text" size="15"> 
    	  </td></tr>
     
    	  <tr id="multiple1" style="display: 'none'"> 
          <td class="lbl"><span class="requiredFieldIndicator">* </span><%=labelBean.getLabel("TO_CHEQUE_NUMBER")%></td>
          <td  class="lbl"width="10">:</td>
          <td colspan="2" align="left"> 	
    	   <input name="chqNumTo" type="text" size="15"> 
    	   </td></tr>
     
     
    	<tr>	  
    	  <td class="lbl"><span class="requiredFieldIndicator">* </span><%=labelBean.getLabel("REASON")%></td>
    	  <td  class="lbl" width="10" >:</td>
    	  <td colspan="2">
    	  <select name="reason">
    	  <option value="Lost"><%=labelBean.getLabel("LOST")%></option>
    	  <option value="Stolen"><%=labelBean.getLabel("STOLEN")%></option>
    	  <option value="Payment Cancellation"><%=labelBean.getLabel("PAYMENT_CANCELLATION")%></option>
    	  <option value="Others"><%=labelBean.getLabel("OTHERS")%></option>	  
    	  </select>
    	  </td>
     
    	</tr>
     
        <br/>
            <tr> 
          <td colspan="3">&nbsp;</td>
        </tr>
        <tr> 
          <td colspan="3" align="center"> 
          <input  class="button" type="submit" value="Next" onClick="return validateAndSubmit();" >      
          </td>
        </tr>
        <tr> 
          <td colspan="3">&nbsp;</td>
        </tr>
    	<tr> 
          <td colspan="3"  align="left" class="footer"><%=labelBean.getLabel("NOTE")%>
           </td>
        </tr>
    	<tr><td colspan="3" class="footer">
    	 <ul>
             <li><%=labelBean.getLabel("THE_ASTERISK")%></li>
         </ul>
    	</td>
    	</tr>
     
      </table>
     
     
    <jsp:include page="/Footer.jsp" />
     </form>
    </body>
    </html>

    **********
    The question is how i validate cheque number only if single radio button selected?thanks
    **********
    Single

    Multiple
    Last edited by Json; April 19th, 2011 at 02:35 AM. Reason: Fixed highlight tags


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: If single radio button selected,validate single field else select double field

    I have moved your thread to a more appropriate topic, and please do not double post the same question. Your other thread has been removed.

  3. #3
    Junior Member
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: If single radio button selected,validate single field else select double field

    HELP!! no people?

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: If single radio button selected,validate single field else select double field

    Quote Originally Posted by gsting_88 View Post
    HELP!! no people?
    If you want more expedient and valuable input, I suggest you trim the code down to only the necessary elements (an SSCCE) and ask a more defined question (you have posted a lot of code - that is more html than java - without a clearly defined question). To complicate matters, the code uses javascript, jsp, and html - a lot of languages that require a container environment that is hard to reproduce.

Similar Threads

  1. Odd Instance Field Issue
    By destructobob in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 8th, 2011, 01:46 AM
  2. Replies: 3
    Last Post: February 21st, 2011, 07:25 PM
  3. Using a password field
    By javapenguin in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 10th, 2010, 11:54 AM
  4. password field, with focused "Enter" button
    By chronoz13 in forum Java Swing Tutorials
    Replies: 1
    Last Post: June 13th, 2010, 05:00 PM