简体   繁体   中英

Validation of radio button in cakephp

I want to validate radio button, when i checked radio button textbox will be disabled, but it cant happens. what will be the exact js for validate radio button.

My JS code is :

function selection_project_phd() { var phds = document.getElementById('EmployeeGuidedProjectPhd').value; var projs = document.getElementById('EmployeeGuidedProjectProject').value; var course_name = document.getElementById('EmployeeGuidedProjectCourseName').value; if(phds == 1) { course_name.disable=true; return false; } else if(projs==0) { course_name.disable=false; return false; } return true; }

This one is View file .ctp code

Phd Project

function selection_project_phd() { 
    var phds = document.getElementById('EmployeeGuidedProjectPhd').checked; 
    var projs = document.getElementById('EmployeeGuidedProjectProject').checked; 
    var course_name = document.getElementById('EmployeeGuidedProjectCourseName'); 
    if(phds) { course_name.disable=true; return false; } 
    else if(projs !== true ) { course_name.disable=false; return false; } 
    return true;  
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM