Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function if statement 1

Status
Not open for further replies.

JohnShell

Technical User
Aug 29, 2003
35
US
Hi,

Have coldfusion textarea and want to insure user makes entry before submit to server processed. I am doing this wrong - any suggestions to correct are greatly appreciated.

<script type="text/javascript">
function rationale()
{
var denInfo = document.getElementById("denialReason");

If(denInfo != "")
{
return true;
}
else
{
alert("Please enter reason in Rationale for Request Denial.");
return false;
}
}
</script>

Submit button code:

<cfinput type="submit" id="denied" name="decDenied" value="Request Denied" style="vertical-align:bottom; visibility:hidden" onClick="rationale();">

Thank you - John
 
denInfo is the DOM element, not the value of the element.
Code:
if(denInfo.value != "") return true;

alert("Please enter reason in Rationale for Request Denial.");
return false;

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Additionally, you want to return either true or false to the onclick event of the button, otherwise it will submit regardless so:

Code:
<cfinput type="submit" id="denied" name="decDenied" value="Request Denied" style="vertical-align:bottom; visibility:hidden" onClick="[red]return[/red] rationale();">



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top