Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi friends,

i need to validate textarea(tinymce), and radio button(aleast one must be selected) at same time when button click.

i have validation code for both, but its different function, how i call or how i merge these two function,pls find below my code

textarea(tinymce) validation
==============================
JavaScript
<script type="text/javascript">
  function validate_textarea() {
            var textarea = tinyMCE.get('textar_Question1').getContent(); 
            if ( (textarea=="") || (textarea==null) ) 
			{
			$('#divValidaTetextarea').modal({show:true})
                    //alert("Post body must not be left blank");
                    //textarea.focus();
                    return false; 
            }
			else
			{
			alert("ok");
			}
    }

</script>


Radio validation
================
JavaScript
function isOneChecked() {
 var chx = document.getElementsByTagName('input');
  for (var i=0; i<chx.length; i++) {
  if (chx[i].type == 'radio' && chx[i].checked) {
      return true;
    } 
  }
  alert("Please select option");
  // End of the loop, return false
  return false;
}



html
=====
HTML
<a type="button" id="btnAddQuestion" class="btn" >AddQuestion</a>



anyone pls share with me your ideas.

thanks :)
Posted
Comments
NowYouSeeMe 24-Sep-14 23:43pm    
why dont you just call tht two functions back to back in your button click
Renga.g 24-Sep-14 23:46pm    
kindly pls explain little more, bcz im trying that but its not working, im not clear how to call like back to back.
Renga.g 24-Sep-14 23:50pm    
yah i found ready, thanks a lot ,thanks for your time.

:)
Renga.g 25-Sep-14 0:04am    
but i have some trouble, i need to show and hide some divs after validate function call. now what happend the function are working but im not sure where in need to put that hide/show div codes.
NowYouSeeMe 25-Sep-14 0:34am    
when you want to hide/show div

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900