SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post form validate , radio buttons

    Hello

    in "validateField" function radio is not exists and I don't know how can I add a validation rule for radio buttons.
    please help me ....

    this is my code:
    PHP Code:

        
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        <
    html>
        <
    head>
            <
    title>projectsinfocus created by phpFormGenerator</title>
            <
    meta http-equiv="content-type" content="text/html; charset=UTF-8"><link href="style.css" rel="stylesheet" type="text/css">
            <!-- 
    calendar stuff -->
                  <
    link rel="stylesheet" type="text/css" href="calendar/calendar-blue2.css" />
                  <
    script type="text/javascript" src="calendar/calendar.js"></script>
                  <script type="text/javascript" src="calendar/calendar-en.js"></script>
                  <script type="text/javascript" src="calendar/calendar-setup.js"></script>
            <!-- END calendar stuff -->

            <!-- expand/collapse function -->
            <SCRIPT type=text/javascript>
            <!--
            function collapseElem(obj)
            {
                var el = document.getElementById(obj);
                el.style.display = 'none';
            }


            function expandElem(obj)
            {
                var el = document.getElementById(obj);
                el.style.display = '';
            }


            //-->
            </SCRIPT>
            <!-- expand/collapse function -->


            <!-- expand/collapse function -->
                <SCRIPT type=text/javascript>
                <!--

                // collapse all elements, except the first one
                function collapseAll()
                {
                    var numFormPages = 3;

                    for(i=2; i <= numFormPages; i++)
                    {
                        currPageId = ('mainForm_' + i);
                        collapseElem(currPageId);
                    }
                }


                //-->
                </SCRIPT>
            <!-- expand/collapse function -->


             <!-- validate -->
            <SCRIPT type=text/javascript>
            <!--
                function validateField(fieldId, fieldBoxId, fieldType, required)
                {
                    fieldBox = document.getElementById(fieldBoxId);
                    fieldObj = document.getElementById(fieldId);

                    if(fieldType == 'text'  ||  fieldType == 'textarea' ||  fieldType == 'password'  ||  fieldType == 'file'  ||  fieldType == 'phone'  || fieldType == 'website')
                    {    
                        if(required == 1 && fieldObj.value == '')
                        {
                            fieldObj.setAttribute("class","mainFormError");
                            fieldObj.setAttribute("className","mainFormError");
                            fieldObj.focus();
                            return false;                    
                        }

                    }


                    else if(fieldType == 'menu'  || fieldType == 'country'  || fieldType == 'state')
                    {    
                        if(required == 1 && fieldObj.selectedIndex == 0)
                        {                
                            fieldObj.setAttribute("class","mainFormError");
                            fieldObj.setAttribute("className","mainFormError");
                            fieldObj.focus();
                            return false;                    
                        }

                    }


                    else if(fieldType == 'email')
                    {    
                        if((required == 1 && fieldObj.value=='')  ||  (fieldObj.value!=''  && !validate_email(fieldObj.value)))
                        {                
                            fieldObj.setAttribute("class","mainFormError");
                            fieldObj.setAttribute("className","mainFormError");
                            fieldObj.focus();
                            return false;                    
                        }

                    }


                }

                function validate_email(emailStr)
                {        
                    apos=emailStr.indexOf("@");
                    dotpos=emailStr.lastIndexOf(".");

                    if (apos<1||dotpos-apos<2) 
                    {
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }


                function validateDate(fieldId, fieldBoxId, fieldType, required,  minDateStr, maxDateStr)
                {
                    retValue = true;

                    fieldBox = document.getElementById(fieldBoxId);
                    fieldObj = document.getElementById(fieldId);    
                    dateStr = fieldObj.value;


                    if(required == 0  && dateStr == '')
                    {
                        return true;
                    }


                    if(dateStr.charAt(2) != '/'  || dateStr.charAt(5) != '/' || dateStr.length != 10)
                    {
                        retValue = false;
                    }    

                    else    // format's okay; check max, min
                    {
                        currDays = parseInt(dateStr.substr(0,2),10) + parseInt(dateStr.substr(3,2),10)*30  + parseInt(dateStr.substr(6,4),10)*365;
                        //alert(currDays);

                        if(maxDateStr != '')
                        {
                            maxDays = parseInt(maxDateStr.substr(0,2),10) + parseInt(maxDateStr.substr(3,2),10)*30  + parseInt(maxDateStr.substr(6,4),10)*365;
                            //alert(maxDays);
                            if(currDays > maxDays)
                                retValue = false;
                        }

                        if(minDateStr != '')
                        {
                            minDays = parseInt(minDateStr.substr(0,2),10) + parseInt(minDateStr.substr(3,2),10)*30  + parseInt(minDateStr.substr(6,4),10)*365;
                            //alert(minDays);
                            if(currDays < minDays)
                                retValue = false;
                        }
                    }

                    if(retValue == false)
                    {
                        fieldObj.setAttribute("class","mainFormError");
                        fieldObj.setAttribute("className","mainFormError");
                        fieldObj.focus();
                        return false;
                    }
                }
            //-->
            </SCRIPT>
            <!-- end validate -->




        </head>

        <body onLoad="collapseAll()">

        <div id="mainForm">




            <div id="formHeader">
                    <h2 class="formInfo">projectsinfocus</h2>
                    <p class="formInfo">Project Foundations Self-assessment</p>
            </div>


            <BR/><!-- begin form -->
            <form method=post enctype=multipart/form-data action=processor.php onSubmit="return validatePage3();"><ul class=mainForm id="mainForm_1">

                    <li class="mainForm" id="fieldBox_1">
                        <label class="formFieldQuestion">User Name&nbsp;*</label><input class=mainForm type=text name=field_1 id=field_1 size='20' value=''></li>

                    <li class="mainForm" id="fieldBox_2">
                        <label class="formFieldQuestion">Email Address&nbsp;*</label><input class=mainForm type=email name=field_2 id=field_2 size=20 value="" style="background-image:url(imgs/email.png); background-repeat: no-repeat;  padding: 2px 2px 2px 25px;"></li>

                    <li class="mainForm" id="fieldBox_3">
                        <label class="formFieldQuestion">Project Name&nbsp;*</label><input class=mainForm type=text name=field_3 id=field_3 size='20' value=''></li>

                    <li class="mainForm" id="fieldBox_4">
                        <label class="formFieldQuestion">What section do you want to go to next?&nbsp;*</label><span><input class=mainForm type=radio name=field_4 id=field_4_option_1 value="Project Foundations Assessment" /><label class=formFieldOption for="field_4_option_1">Project Foundations Assessment</label><input class=mainForm type=radio name=field_4 id=field_4_option_2 value="Project Context (Project Scope & then Project Performance)" /><label class=formFieldOption for="field_4_option_2">Project Context (Project Scope & then Project Performance)</label></span></li>
            
            
            <!-- end of this page -->

            <!-- page validation -->
            <SCRIPT type=text/javascript>
            <!--
                function validatePage1()
                {
                    retVal = true;

    if (validateField('field_1','fieldBox_1','text',1) == false)
     retVal=false;
    if (validateField('field_2','fieldBox_2','email',1) == false)
     retVal=false;
    if (validateField('field_3','fieldBox_3','text',1) == false)
     retVal=false;
    if (validateField('field_4','fieldBox_4','radio',1) == false)
     retVal=false;


                    if(retVal == false)
                    {
                        alert('Please correct the errors.  Fields marked with an asterisk (*) are required');
                        return false;
                    }
                    return retVal;
                }
            //-->
            </SCRIPT>

            <!-- end page validaton -->



            <!-- next page buttons --><li class="mainForm">
                        <input type=button onClick="if (validatePage1()) { collapseElem('mainForm_1'); expandElem('mainForm_2');}" class="mainForm" value="Go to page 2"/>    
                    </li>
            <!-- close the display stuff for this page -->
            </ul><ul class=mainForm id="mainForm_2">

                    <li class="mainForm" id="fieldBox_5">
                        <label class="formFieldQuestion">Please review descriptions on the right to determine which answer best describes your project?&nbsp;*</label><span><input class=mainForm type=radio name=field_5 id=field_5_option_1 value="4 - Excellent Stakeholder involvement" /><label class=formFieldOption for="field_5_option_1">4 - Excellent Stakeholder involvement</label><input class=mainForm type=radio name=field_5 id=field_5_option_2 value="3 - Good Stakeholder involvement" /><label class=formFieldOption for="field_5_option_2">3 - Good Stakeholder involvement</label><input class=mainForm type=radio name=field_5 id=field_5_option_3 value="2 - Poor stakeholder involvement" /><label class=formFieldOption for="field_5_option_3">2 - Poor stakeholder involvement</label><input class=mainForm type=radio name=field_5 id=field_5_option_4 value="1 - Problematic stakeholder involvement" /><label class=formFieldOption for="field_5_option_4">1 - Problematic stakeholder involvement</label><input class=mainForm type=radio name=field_5 id=field_5_option_5 value="0 - Not answered yet" /><label class=formFieldOption for="field_5_option_5">0 - Not answered yet</label><input class=mainForm type=radio name=field_5 id=field_5_option_6 value="N - Not applicable" /><label class=formFieldOption for="field_5_option_6">N - Not applicable</label></span></li>

                    <li class="mainForm" id="fieldBox_6">
                        <label class="formFieldQuestion">OPTIONAL: Please provide further information &/or feedback on Question #1 on stakeholder involvement</label><textarea class=mainForm  name=field_6 id=field_6 rows=4 cols=20></textarea></li>

                    <li class="mainForm" id="fieldBox_7">
                        <label class="formFieldQuestion">Please review descriptions on the right of this question to determine which answer best describes your project?&nbsp;*</label><span><input class=mainForm type=radio name=field_7 id=field_7_option_1 value="4 - Excellent project sponsorship" /><label class=formFieldOption for="field_7_option_1">4 - Excellent project sponsorship</label><input class=mainForm type=radio name=field_7 id=field_7_option_2 value="3 - Good project sponsorship" /><label class=formFieldOption for="field_7_option_2">3 - Good project sponsorship</label><input class=mainForm type=radio name=field_7 id=field_7_option_3 value="2 - Poor project sponsorship" /><label class=formFieldOption for="field_7_option_3">2 - Poor project sponsorship</label><input class=mainForm type=radio name=field_7 id=field_7_option_4 value="1 - Problematic project sponsorship" /><label class=formFieldOption for="field_7_option_4">1 - Problematic project sponsorship</label><input class=mainForm type=radio name=field_7 id=field_7_option_5 value="0 - Not answered yet" /><label class=formFieldOption for="field_7_option_5">0 - Not answered yet</label><input class=mainForm type=radio name=field_7 id=field_7_option_6 value="N - Not applicable" /><label class=formFieldOption for="field_7_option_6">N - Not applicable</label></span></li>

                    <li class="mainForm" id="fieldBox_8">
                        <label class="formFieldQuestion">OPTIONAL: Please provide further information &/or feedback on Question #3 on Project Sponsorship within organization</label><textarea class=mainForm  name=field_8 id=field_8 rows=4 cols=20></textarea></li>

                    <li class="mainForm" id="fieldBox_9">
                        <label class="formFieldQuestion">Please review descriptions on the right of this question to determine which answer best describes your project?&nbsp;*</label><span><input class=mainForm type=radio name=field_9 id=field_9_option_1 value="4 - Excellent at establishing project direction & related support?" /><label class=formFieldOption for="field_9_option_1">4 - Excellent at establishing project direction & related support?</label><input class=mainForm type=radio name=field_9 id=field_9_option_2 value="3 - Good at establishing project direction & related support?" /><label class=formFieldOption for="field_9_option_2">3 - Good at establishing project direction & related support?</label><input class=mainForm type=radio name=field_9 id=field_9_option_3 value="2 - Poor at establishing project direction & related support?" /><label class=formFieldOption for="field_9_option_3">2 - Poor at establishing project direction & related support?</label><input class=mainForm type=radio name=field_9 id=field_9_option_4 value="1 - Problematic at establishing project direction & related support?" /><label class=formFieldOption for="field_9_option_4">1 - Problematic at establishing project direction & related support?</label><input class=mainForm type=radio name=field_9 id=field_9_option_5 value="0 - Not answered yet" /><label class=formFieldOption for="field_9_option_5">0 - Not answered yet</label><input class=mainForm type=radio name=field_9 id=field_9_option_6 value="N - Not applicable" /><label class=formFieldOption for="field_9_option_6">N - Not applicable</label></span></li>

                    <li class="mainForm" id="fieldBox_10">
                        <label class="formFieldQuestion">OPTIONAL: Please provide further information &/or feedback on Question #5 on Project Direction & Related Support</label><textarea class=mainForm  name=field_10 id=field_10 rows=4 cols=20></textarea></li>

                    <li class="mainForm" id="fieldBox_11">
                        <label class="formFieldQuestion">Please review descriptions on the right of this question to determine which answer best describes your project?&nbsp;*</label><span><input class=mainForm type=radio name=field_11 id=field_11_option_1 value="4 - Excellent at developing a tight scope for delivery phases of the project?" /><label class=formFieldOption for="field_11_option_1">4 - Excellent at developing a tight scope for delivery phases of the project?</label><input class=mainForm type=radio name=field_11 id=field_11_option_2 value="3 - Good at developing a tight scope for delivery phases of the project?" /><label class=formFieldOption for="field_11_option_2">3 - Good at developing a tight scope for delivery phases of the project?</label><input class=mainForm type=radio name=field_11 id=field_11_option_3 value="2 - Poor at developing a tight scope for delivery phases of the project?" /><label class=formFieldOption for="field_11_option_3">2 - Poor at developing a tight scope for delivery phases of the project?</label><input class=mainForm type=radio name=field_11 id=field_11_option_4 value="1 - Problematic at developing a tight scope for delivery phases of the project?" /><label class=formFieldOption for="field_11_option_4">1 - Problematic at developing a tight scope for delivery phases of the project?</label><input class=mainForm type=radio name=field_11 id=field_11_option_5 value="0 - Not answered yet" /><label class=formFieldOption for="field_11_option_5">0 - Not answered yet</label><input class=mainForm type=radio name=field_11 id=field_11_option_6 value="N - Not applicable" /><label class=formFieldOption for="field_11_option_6">N - Not applicable</label></span></li>

                    <li class="mainForm" id="fieldBox_12">
                        <label class="formFieldQuestion">OPTIONAL: Please provide further information &/or feedback on Question #7 on developing a tight scope for delivery phases of the project?</label><textarea class=mainForm  name=field_12 id=field_12 rows=4 cols=20></textarea></li>

                    <li class="mainForm" id="fieldBox_13">
                        <label class="formFieldQuestion">Please review descriptions on the right of this question to determine which answer best describes your project?&nbsp;*</label><span><input class=mainForm type=radio name=field_13 id=field_13_option_1 value="4 - Excellent level of agility in project delivery" /><label class=formFieldOption for="field_13_option_1">4 - Excellent level of agility in project delivery</label><input class=mainForm type=radio name=field_13 id=field_13_option_2 value="3 - Good level of agility in project delivery" /><label class=formFieldOption for="field_13_option_2">3 - Good level of agility in project delivery</label><input class=mainForm type=radio name=field_13 id=field_13_option_3 value="2 - Poor level of agility in project delivery" /><label class=formFieldOption for="field_13_option_3">2 - Poor level of agility in project delivery</label><input class=mainForm type=radio name=field_13 id=field_13_option_4 value="1 - Problematic level of agility in project delivery" /><label class=formFieldOption for="field_13_option_4">1 - Problematic level of agility in project delivery</label><input class=mainForm type=radio name=field_13 id=field_13_option_5 value="0 - Not answered yet" /><label class=formFieldOption for="field_13_option_5">0 - Not answered yet</label><input class=mainForm type=radio name=field_13 id=field_13_option_6 value="N - Not applicable" /><label class=formFieldOption for="field_13_option_6">N - Not applicable</label></span></li>

                    <li class="mainForm" id="fieldBox_14">
                        <label class="formFieldQuestion">OPTIONAL: Please provide further information &/or feedback on Question #9 on Level of agility in project delivery</label><textarea class=mainForm  name=field_14 id=field_14 rows=4 cols=20></textarea></li>

                    <li class="mainForm" id="fieldBox_15">
                        <label class="formFieldQuestion">Please review descriptions on the right of this question to determine which answer best describes your project&nbsp;*</label><span><input class=mainForm type=radio name=field_15 id=field_15_option_1 value="4 - Excellently productive project team" /><label class=formFieldOption for="field_15_option_1">4 - Excellently productive project team</label><input class=mainForm type=radio name=field_15 id=field_15_option_2 value="3 - Productive project team" /><label class=formFieldOption for="field_15_option_2">3 - Productive project team</label><input class=mainForm type=radio name=field_15 id=field_15_option_3 value="2 - Fairly unproductive project team" /><label class=formFieldOption for="field_15_option_3">2 - Fairly unproductive project team</label><input class=mainForm type=radio name=field_15 id=field_15_option_4 value="1 - Unproductive project team" /><label class=formFieldOption for="field_15_option_4">1 - Unproductive project team</label><input class=mainForm type=radio name=field_15 id=field_15_option_5 value="0 - Not answered yet" /><label class=formFieldOption for="field_15_option_5">0 - Not answered yet</label><input class=mainForm type=radio name=field_15 id=field_15_option_6 value="N - Not applicable" /><label class=formFieldOption for="field_15_option_6">N - Not applicable</label></span></li>

                    <li class="mainForm" id="fieldBox_16">
                        <label class="formFieldQuestion">OPTIONAL: Please provide further information &/or feedback on Question #11 on engaging & building a productive team</label><textarea class=mainForm  name=field_16 id=field_16 rows=4 cols=20></textarea></li>

                    <li class="mainForm" id="fieldBox_17">
                        <label class="formFieldQuestion">Please review descriptions on the right of this question to determine which answer best describes your project&nbsp;*</label><span><input class=mainForm type=radio name=field_17 id=field_17_option_1 value="4 - Excellent project communication" /><label class=formFieldOption for="field_17_option_1">4 - Excellent project communication</label><input class=mainForm type=radio name=field_17 id=field_17_option_2 value="3 - Good project communication" /><label class=formFieldOption for="field_17_option_2">3 - Good project communication</label><input class=mainForm type=radio name=field_17 id=field_17_option_3 value="2 - Poor project communication" /><label class=formFieldOption for="field_17_option_3">2 - Poor project communication</label><input class=mainForm type=radio name=field_17 id=field_17_option_4 value="1 - Problematic project communication" /><label class=formFieldOption for="field_17_option_4">1 - Problematic project communication</label><input class=mainForm type=radio name=field_17 id=field_17_option_5 value="0 - Not answered yet" /><label class=formFieldOption for="field_17_option_5">0 - Not answered yet</label><input class=mainForm type=radio name=field_17 id=field_17_option_6 value="N - Not applicable" /><label class=formFieldOption for="field_17_option_6">N - Not applicable</label></span></li>

                    <li class="mainForm" id="fieldBox_18">
                        <label class="formFieldQuestion">OPTIONAL: Please provide further information &/or feedback on Question #13 on quality of communications</label><textarea class=mainForm  name=field_18 id=field_18 rows=4 cols=20></textarea></li>

                    <li class="mainForm" id="fieldBox_19">
                        <label class="formFieldQuestion">Please review descriptions on the right of this question to determine which answer best describes your project&nbsp;*</label><span><input class=mainForm type=radio name=field_19 id=field_19_option_1 value="4 - Excellent project financial management" /><label class=formFieldOption for="field_19_option_1">4 - Excellent project financial management</label><input class=mainForm type=radio name=field_19 id=field_19_option_2 value="3 - Good project financial management" /><label class=formFieldOption for="field_19_option_2">3 - Good project financial management</label><input class=mainForm type=radio name=field_19 id=field_19_option_3 value="2 - Poor project financial management" /><label class=formFieldOption for="field_19_option_3">2 - Poor project financial management</label><input class=mainForm type=radio name=field_19 id=field_19_option_4 value="1 - Problematic project financial management" /><label class=formFieldOption for="field_19_option_4">1 - Problematic project financial management</label><input class=mainForm type=radio name=field_19 id=field_19_option_5 value="0 - Not answered yet" /><label class=formFieldOption for="field_19_option_5">0 - Not answered yet</label><input class=mainForm type=radio name=field_19 id=field_19_option_6 value="N - Not applicable" /><label class=formFieldOption for="field_19_option_6">N - Not applicable</label></span></li>

                    <li class="mainForm" id="fieldBox_20">
                        <label class="formFieldQuestion">OPTIONAL: Please provide further information &/or feedback on Question #15 on project financial management And any overall feedback on questionnaire. Many thanks.</label><textarea class=mainForm  name=field_20 id=field_20 rows=4 cols=20></textarea></li>
            
            
            <!-- end of this page -->

            <!-- page validation -->
            <SCRIPT type=text/javascript>
            <!--
                function validatePage2()
                {
                    retVal = true;
                    if (validateField('field_5','fieldBox_5','radio',1) == false)
     retVal=false;
    if (validateField('field_6','fieldBox_6','textarea',0) == false)
     retVal=false;
    if (validateField('field_7','fieldBox_7','radio',1) == false)
     retVal=false;
    if (validateField('field_8','fieldBox_8','textarea',0) == false)
     retVal=false;
    if (validateField('field_9','fieldBox_9','radio',1) == false)
     retVal=false;
    if (validateField('field_10','fieldBox_10','textarea',0) == false)
     retVal=false;
    if (validateField('field_11','fieldBox_11','radio',1) == false)
     retVal=false;
    if (validateField('field_12','fieldBox_12','textarea',0) == false)
     retVal=false;
    if (validateField('field_13','fieldBox_13','radio',1) == false)
     retVal=false;
    if (validateField('field_14','fieldBox_14','textarea',0) == false)
     retVal=false;
    if (validateField('field_15','fieldBox_15','radio',1) == false)
     retVal=false;
    if (validateField('field_16','fieldBox_16','textarea',0) == false)
     retVal=false;
    if (validateField('field_17','fieldBox_17','radio',1) == false)
     retVal=false;
    if (validateField('field_18','fieldBox_18','textarea',0) == false)
     retVal=false;
    if (validateField('field_19','fieldBox_19','radio',1) == false)
     retVal=false;
    if (validateField('field_20','fieldBox_20','textarea',0) == false)
     retVal=false;

                    if(retVal == false)
                    {
                        alert('Please correct the errors.  Fields marked with an asterisk (*) are required');
                        return false;
                    }
                    return retVal;
                }
            //-->
            </SCRIPT>

            <!-- end page validaton -->



            <!-- next page buttons --><li class="mainForm">
                        <input type=button onClick="if (validatePage2()) { collapseElem('mainForm_2'); expandElem('mainForm_3');}" class="mainForm" value="Go to page 3"/>    
                    </li>
            <!-- close the display stuff for this page -->
            </ul><ul class=mainForm id="mainForm_3">

                    <li class="mainForm" id="fieldBox_21">
                        <label class="formFieldQuestion">If you have completed the questionnaire, you will receive an email from Projects in Focus with a summary of your results.&nbsp;*</label><span><input class=mainForm type=radio name=field_21 id=field_21_option_1 value="Completed the questionnaire" /><label class=formFieldOption for="field_21_option_1">Completed the questionnaire</label><input class=mainForm type=radio name=field_21 id=field_21_option_2 value="Will be returning to edit the answers further" /><label class=formFieldOption for="field_21_option_2">Will be returning to edit the answers further</label></span></li>

                    <li class="mainForm" id="fieldBox_22">
                        <label class="formFieldQuestion">Now you have completed or finished working with the project foundation questions, what do you want to do now?&nbsp;*</label><span><input class=mainForm type=radio name=field_22 id=field_22_option_1 value="Go to section on project context (project scope & performance)" /><label class=formFieldOption for="field_22_option_1">Go to section on project context (project scope & performance)</label><input class=mainForm type=radio name=field_22 id=field_22_option_2 value="Please email me the report as a basis to start a conversation on how "Projects in Focus" can help" /><label class=formFieldOption for="field_22_option_2">Please email me the report as a basis to start a conversation on how "Projects in Focus" can help</label><input class=mainForm type=radio name=field_22 id=field_22_option_3 value="Please email me the report (but do not start a conversation)" /><label class=formFieldOption for="field_22_option_3">Please email me the report (but do not start a conversation)</label><input class=mainForm type=radio name=field_22 id=field_22_option_4 value="Exit (do not email me answers or start a conversation)" /><label class=formFieldOption for="field_22_option_4">Exit (do not email me answers or start a conversation)</label></span></li>

                    <li class="mainForm" id="fieldBox_23">
                        <label class="formFieldQuestion">Please provide any overall feedback on the questionnaire</label><textarea class=mainForm  name=field_23 id=field_23 rows=20 cols=20></textarea></li>
            
            
            <!-- end of this page -->

            <!-- page validation -->
            <SCRIPT type=text/javascript>
            <!--
                function validatePage3()
                {
                    retVal = true;
                    if (validateField('field_21','fieldBox_21','radio',1) == false)
     retVal=false;
    if (validateField('field_22','fieldBox_22','radio',1) == false)
     retVal=false;
    if (validateField('field_23','fieldBox_23','textarea',0) == false)
     retVal=false;

                    if(retVal == false)
                    {
                        alert('Please correct the errors.  Fields marked with an asterisk (*) are required');
                        return false;
                    }
                    return retVal;
                }
            //-->
            </SCRIPT>

            <!-- end page validaton -->



            <!-- next page buttons --><li class="mainForm">
                        <input id="saveForm" class="mainForm" type="submit" value="Submit" />
                    </li>

                </form>
                <!-- end of form -->
            <!-- close the display stuff for this page -->
            </ul></div><div id="footer"><p class="footer"><a class=footer href=http://phpformgen.sourceforge.net>Generated by phpFormGenerator</a></p></div>

        </body>
        </html> 

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,810
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    For radio buttons you have to loop through the array of buttons to find which one is set. If you get to the end without finding one that's set then you report that the field isn't valid.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •