JavaScript

Moderators: None (Apply to moderate this forum)
Number of threads: 2058
Number of posts: 5158

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
radio button validation Posted by drpagal on 9 Jun 2009 at 11:39 AM
Currently without any javascript if a user does not select a radio button, it goes to a Coldfusion error page. Someone before me wrote the actual page and I, of course, needs to fix it. So i'm trying to add the following javascript and still goes to the cf error page. Any help would be great!




<script type="text/javascript">
function validate()
{
var a = document.getElementById('Abstract');
var b = document.getElementById('Book');
var c = document.getElementById('Paper');
var d = document.getElementById('Presentation');
var e = document.getElementById('Oral');
var f = document.getElementById('Journal');
var g = document.getElementById('Public');
var h = document.getElementById('Internal');
var i = document.getElementById('Good');
if ( (a.checked == false )
&& (b.checked == false )
&& (c.checked == false )
&& (d.checked == false )
&& (e.checked == false )
&& (f.checked == false )
&& (g.checked == false )
&& (h.checked == false )
&& (i.checked == false ) )
{
alert ( "Please Choose Document Type" );
document.frmSubscription.document.focus();
return false;
}
return true;
}
</script>


===
<cfform name="frmSubscription" onSubmit="return ValidateForm(); return validate();">
===


<input id="Abstract" type="radio" value="Abstract" name="document">
<input id="Book" type="radio" name="document" value="Book">
<input id="Paper" type="radio" value="Paper" name="document">
<input id="Presentation" type="radio" value="Presentation" name="document" >
<input id="Oral" type="radio" value="Oral Visual Presentation" name="document">
<input id="Journal" type="radio" name="document" value="Journal Article">
<input id="Public" type="radio" name="document" value="Public Web Site">
<input id="Internal" type="radio" value="Internal Web Site" name="document" >
<input id="Good" name="document" type="radio" value="Good Doc Report">


Report
Re: radio button validation Posted by CyGuy on 10 Jun 2009 at 4:29 AM
Coldfusion is not my forte, but there is a tag that is documented here specifically stating that java is required along with an action attribute to that tag.

Adding events is complicated enough without returning values. I suggest you simplify the javascript in the onclick by limiting validation to a single function. Perhaps by placing the ValidateForm() function inside the validate function assuming ValidateForm has been declared.

Report
Re: radio button validation Posted by CyGuy on 10 Jun 2009 at 4:30 AM
Coldfusion is not my forte, but there is a tag that is documented here specifically stating that java is required along with an action attribute to that tag.

Adding events is complicated enough without returning values. I suggest you simplify the javascript in the onclick by limiting validation to a single function. Perhaps by placing the ValidateForm() function inside the validate function assuming ValidateForm has been declared.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.