Click here to Skip to main content
15,567,786 members
Home / Discussions / Java
   

Java

 
GeneralRe: Some exception Problem Pin
Richard MacCutchan6-Jan-10 3:03
mveRichard MacCutchan6-Jan-10 3:03 
GeneralRe: Some exception Problem Pin
David Skelly6-Jan-10 3:03
David Skelly6-Jan-10 3:03 
GeneralRe: Some exception Problem Pin
Richard MacCutchan6-Jan-10 3:17
mveRichard MacCutchan6-Jan-10 3:17 
GeneralRe: Some exception Problem Pin
002comp6-Jan-10 20:08
002comp6-Jan-10 20:08 
QuestionClient-Server Pin
Gjm4-Jan-10 2:19
Gjm4-Jan-10 2:19 
AnswerRe: Client-Server Pin
Nagy Vilmos4-Jan-10 3:03
professionalNagy Vilmos4-Jan-10 3:03 
QuestionFlexigrid with JSP/Servlet Pin
pdoy07083-Jan-10 15:19
pdoy07083-Jan-10 15:19 
Questionmy validation form not working - pls advise. tks. Pin
karengsh30-Dec-09 6:16
karengsh30-Dec-09 6:16 
<script language="javascript">
            function checkForm(){
                var objForm = new Object();
                var objFullNameTextBox = new Object();
                var objMessageBox = new Object();
                var objAddress = new Object();
                var objNRIC = new Object();
                var objContact = new Object();
                var objEmail = new Object();
                var objDOB = new Object();
                var objGender = new Object();
                var objType = new Object();
                var objRemarks = new Object();
                var strMemberName = new String("");
                var strEmail = new String("");
                var strAddress = new String("");
                var strNRIC = new String("");
                var strContact = new String("");
                var strGender = new String("");
                var strType = new String("");
                var strRemarks = new String("");
                var blnIsAllOkay = new Boolean(true);
                var strMessageToUser = new String("");

                objForm = document.getElementById("frmData");
                objFullNameTextBox = document.getElementById("txtFullName");
                objMessageBox = document.getElementById("divMessage");
                objAddress = document.getElementById("txtAddress");
                objNRIC = document.getElementById("txtNRIC");
                objContact = document.getElementById("txtContact");
                objEmail = document.getElementById("txtEmail");
                objGender = document.getElementById("txtGender");
                objType = document.getElementById("txtMember");
                objRemarks = document.getElementById("txtRemarks");

                strEmail = objEmail.value;
                strAddress = objAddress.value;
                strNRIC = objNRIC.value;
                strContact = objContact.value;
                strGender = objGender.value;
                strType = objType.value;
                strRemarks = objRemarks.value;
                strEmail = trimData(strEmail);
                strAddress = trimData(strAddress);
                strNRIC = trimData(strNRIC);
                strContact = trimData(strContact);
                strGender = trimData(strGender);
                strType = trimData(strType);
                strRemarks = trimData(strRemarks);
                strMemberName = objFullNameTextBox.value;
                strMemberName = trimData(strMemberName);
                if (strMemberName=="" ){
                    strMessageToUser += "Please indicate Name<br>";
                    blnIsAllOkay = false;
                }
                if (strNRIC=="" ){
                    strMessageToUser += "Please indicate NRIC No<br>";
                    blnIsAllOkay = false;
                }
                if (strAddress=="" ){
                    strMessageToUser += "Please indicate Address<br>";
                    blnIsAllOkay = false;
                }
                if (strContact=="" ){
                    strMessageToUser += "Please indicate Contact<br>";
                    blnIsAllOkay = false;
                }
                
                //function validateNRIC(pstrData){
                var NRICRegEx = /^[A-Z]\d{7}[A-Z]$/;
                //str = pstrData
                if(strNRIC.match(NRICRegEx)){
                    blnIsAllOkay == true;
                }else {
                    strMessageToUser += "Please indicate correct NRIC.<br>";
                }
                 

                // function validateEmail(pstrData){
                var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                //str = pstrData
                if(strEmail.match(emailRegEx)){
                    blnIsAllOkay == true;
                }else{
                    strMessageToUser += "Please indicate correct email.<br>";
                }                 
                        
                // function validateContact(pstrData){
                var ContactRegEx = /d{8}/;
                //   str = pstrData
                if (strContact.match(ContactRegEx)){
                    blnIsAllOkay == true;
                } else {
                    strMessageToUser += "Please indicate correct Contact Number<br>";
                }
                
                To check that one of the radio buttons for Gender is selected
                 var radioChecked = false;
                for (var i=0; i < strGender.length; i--){
                  if(Gender[i].radioChecked){
                strMessageToUser += "Please check that one of the buttons for Gender is selected>";
                  }

                function trimData(pstrData){
                    var intIndex=0;
                    var intRightIndex= pstrData.length -1;
                    while((intIndex < pstrData.length) && (pstrData.charAt(intIndex) == ' '))
                    {intIndex++; }
                    while((intRightIndex > intIndex) && (pstrData.charAt(intRightIndex) == ' '))
                    {intRightIndex-=1;}
                    return pstrData.substring(intIndex, intRightIndex+1);
                }//end of function trimData

                if (blnIsAllOkay==true){
                    objForm.submit();
                }else{
                    objMessageBox.innerHTML = strMessageToUser;
                }
                  function clearErr() {
                    objMessageBox = document.getElementById("divMessage");
                    objMessageBox.innerHTML = "";
                }
                }
               </script>
    </head>
    <body>
        <form id="frmData" name="frmData" action="addmember"
              method="post" >
            <table border="0" style="width:500px;padding:3px;" >
                <tr>
                    <td colspan="2" class="tdTitle" >Member Registration</td>
                </tr>
                <tr>
                    <td>Full Name</td>
                    <td><input type="text" id="txtFullName" name="txtFullName" value=""></td>
                </tr>
                <tr>
                    <td>Email</td>
                    <td><input type="text" id="txtEmail" name="txtEmail" value=""></td>
                </tr>
                <tr>
                    <td>Address</td>
                    <td><input type="text" id="txtAddress" name="txtAddress" value=""></td>
                </tr>
                <tr>
                    <td>NRIC No</td>
                    <td><input type="text" id="txtNRIC" name="txtNRIC" value=""></td>
                </tr>
                <tr>
                    <td>Contact</td>
                    <td><input type="text" id="txtContact" name="txtContact" value=""></td>
                </tr>
                 <tr>
                    <td>Gender</td>
                    <td><input type="radio" id="txtGender" value="Male" name="txtGender"/>Male
                        <input type="radio" id="txtGender" value="Female" name="txtGender"/>Female</td>
                </tr>
                <tr>
                    <td>Type</td>
                    <td><select name="txtMember" id="txtMember">
                            <option>Member</option>
                            <option>Volunteer</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Remarks</td>
                    <td><input type="text" id="txtRemarks" name="txtRemarks"></td>
                <tr>
                    <td colspan="2"><div id="divMessage"></div></td>
                </tr>
                <tr>
                    <td colspan="2" align="right">
                    <td><input type="button" id="btnSubmit" name="btnSubmit" value="Submit" onclick="checkForm();" /></td>
                        <td><input id="reset" type="reset" value="reset" onclick="clearErr();"/></td>
                </tr>
            </table>
        </form>
    </body>
</html>

AnswerRe: my validation form not working - pls advise. tks. Pin
Richard MacCutchan30-Dec-09 6:44
mveRichard MacCutchan30-Dec-09 6:44 
GeneralRe: my validation form not working - pls advise. tks. Pin
karengsh30-Dec-09 7:31
karengsh30-Dec-09 7:31 
GeneralRe: my validation form not working - pls advise. tks. Pin
karengsh30-Dec-09 7:38
karengsh30-Dec-09 7:38 
GeneralRe: my validation form not working - pls advise. tks. Pin
Richard MacCutchan30-Dec-09 12:01
mveRichard MacCutchan30-Dec-09 12:01 
GeneralRe: my validation form not working - pls advise. tks. Pin
karengsh30-Dec-09 17:05
karengsh30-Dec-09 17:05 
GeneralRe: my validation form not working - pls advise. tks. Pin
Richard MacCutchan31-Dec-09 0:58
mveRichard MacCutchan31-Dec-09 0:58 
QuestionHashMap Pin
002comp29-Dec-09 23:55
002comp29-Dec-09 23:55 
AnswerRe: HashMap Pin
Richard MacCutchan30-Dec-09 0:16
mveRichard MacCutchan30-Dec-09 0:16 
GeneralRe: HashMap Pin
002comp30-Dec-09 19:01
002comp30-Dec-09 19:01 
GeneralRe: HashMap Pin
Cedric Moonen31-Dec-09 0:16
Cedric Moonen31-Dec-09 0:16 
GeneralRe: HashMap Pin
002comp31-Dec-09 0:48
002comp31-Dec-09 0:48 
QuestionError Message - HTTP 500 & Error Message - no servlet mappings in web.xml Pin
karengsh29-Dec-09 1:28
karengsh29-Dec-09 1:28 
AnswerRe: Error Message - HTTP 500 & Error Message - no servlet mappings in web.xml Pin
Richard MacCutchan29-Dec-09 5:39
mveRichard MacCutchan29-Dec-09 5:39 
GeneralRe: Error Message - HTTP 500 & Error Message - no servlet mappings in web.xml Pin
karengsh30-Dec-09 6:06
karengsh30-Dec-09 6:06 
GeneralRe: Error Message - HTTP 500 & Error Message - no servlet mappings in web.xml Pin
Richard MacCutchan30-Dec-09 6:41
mveRichard MacCutchan30-Dec-09 6:41 
QuestionProb in reading .mtl file format. Pin
002comp27-Dec-09 20:35
002comp27-Dec-09 20:35 
Questioncall by value for objects Pin
mesho26-Dec-09 9:52
mesho26-Dec-09 9:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.