Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-14-2009, 09:30 PM   PM User | #1
Mthor
New Coder

 
Join Date: Sep 2008
Posts: 37
Thanks: 5
Thanked 0 Times in 0 Posts
Mthor can only hope to improve
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>
Mthor is offline   Reply With Quote
Old 12-15-2009, 08:02 PM   PM User | #2
tomws
Senior Coder

 
tomws's Avatar
 
Join Date: Nov 2007
Location: Arkansas
Posts: 2,644
Thanks: 29
Thanked 330 Times in 326 Posts
tomws will become famous soon enoughtomws will become famous soon enough
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?
tomws is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:56 PM.


Advertisement
Log in to turn off these ads.