Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2008
    Posts
    37
    Thanks
    5
    Thanked 0 Times in 0 Posts

    javascript validate: 2 form fields cannot have the same value

    in the form below i am trying to make it where Moderator pin must be different than the standard pin and listen only pin. and the Standard Pin must be different than the listen only pin.

    any help is appreciated

    Code:
    <script language="javascript" type="text/javascript">
        function ValidateData(form) {
            var moderatorpin = document.form.moderatorPin.value
            var pin = document.form.memberPin.value
            var listenonlypin = document.form.listenOnlypin.value
    
            var result = false;
            if ((moderatorpin.value == pin.value) || (moderatorpin.value == listenonlypin.value)) alert("Moderator pin must be different than the standard pin and listen only pin.");
            else if (pin.value == listenonlypin.value) alert("Standard Pin must be different than the listen only pin.");
            else result = true;
    
            return result;
        }
    </script>
    Code:
    <form method="POST" action="OutlookWeb.asp" name="form" id="form" onSubmit="return ValidateData(this)">
                <input type="hidden" name="mps" value="VC/StoreConfRoom" />
                <input type="hidden" name="successredirect" value="OutlookWeb.asp?xsl=PortalWeb/MySettings&amp;mps=VC/GetUser"  />
                <input type="hidden" name="id" value="{$roomid}" />
                <input type="hidden" name="maxPorts" value="{$maxports}" />
                <!-- <xsl:choose>
                    <xsl:when test="boolean(getRoomsReturn)">
                    <xsl:apply-templates select="getRoomsReturn"/>
                    </xsl:when>
                    <xsl:otherwise>
                    Must enable the conference room service to access your personal conference room properties.
                    </xsl:otherwise>
                    </xsl:choose> 
                -->
                <table width="100%" height="267" bgcolor="#dfe8f6" cellpadding="0" cellspacing="0">
                    <tr class="headerTab">
                        <td class="caatagories" colspan="2">
                            Conference Room Properties
                        </td>
                    </tr>
                    <tr valign="top">
                        <td class="padding toppadding bottompadding">
                            <table width="50%" height="166" class="border" cellpadding="3" cellspacing="0"
                                bgcolor="#dfe8f6">
                                <tr bgcolor="#ffffff">
                                    <td width="30%" class="text">
                                        Room ID
                                    </td>
                                    <td width="70%">
                                        <input class="inputtext" readonly="readonly" name="roomId" id="cell" size="25" type="text" maxlength="10" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="text">
                                        Description
                                    </td>
                                    <td>
                                        <input class="inputtext" name="description" id="home" size="25" type="text" maxlength="10" value="" />
                                    </td>
                                </tr>
                                <tr bgcolor="#ffffff">
                                    <td class="text">
                                        Moderator Pin
                                    </td>
                                    <td>
                                        <input class="inputtext" name="moderatorPin" id="moderatorPin" size="25" type="text" maxlength="10" value="" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="text">
                                        Pin
                                    </td>
                                    <td>
                                        <input class="inputtext" name="memberPin" id="memberPin" size="25" type="text" maxlength="10" value="" />
                                    </td>
                                </tr>
                                <tr bgcolor="#ffffff">
                                    <td class="text">
                                        Listen Only Pin
                                    </td>
                                    <td>
                                        <input class="inputtext" name="listenOnlyPin" id="listenOnlyPin" size="25" type="text" value="" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="text">
                                    </td>
                                    <td>
                                        <input type="submit" value="Save" name="submit" />
                                        <input type="button" value="Cancel" name="cancel" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </form>

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    It seems you're not using any framework for this, so there was no need to post it way down here. The top-level javascript forum would have offered you more traffic. PM a mod to request a move.

    You didn't state what you think is wrong with the posted code or whether you're receiving any errors. Taking a stab in the dark, I'd guess you might be having a problem in the tests for moderatorpin.value (and the others). You've already assigned moderatorpin (and, again, the others) the values of the form fields. You can't pull a value from a value.
    Are you a Help Vampire?


  •  

    Posting Permissions

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