...

View Full Version : javascript validate: 2 form fields cannot have the same value



Mthor
12-14-2009, 10:30 PM
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


<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>


<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>

tomws
12-15-2009, 09:02 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum