﻿$(document).ready(function(){
    ValidRequired();
    
    $("input").blur(function(event){
        ValidRequired();
    });
    $("input").focus(function(){
        ValidRequired();
    });
    $("input").keyup(function(){
       ValidRequired(); 
    });
  
});

function ValidRequired(){
    post=$("input[name=post]").val();
    surname=$("input[name=surname]").val();
    name=$("input[name=name]").val();
    bod=$("input[name=birthday]").val();
    mobile=$("input[name=mobile_phone]").val();
    email=$("input[name=email]").val();
    family=$("select[name=family_status] option:selected").val();
    edu_level=$("select[name=edu_level] option:selected").val();
    inst_name=$("input[name=institution_name]").val();
    edu_period=$("input[name=edu_period]").val();
    edu_spec=$("input[name=edu_speciality]").val();
    captcha=$("input[name=captcha_form]").val();
    captcha_sum=$("input[name=md5]").val();
    
    
    if(post!='' && surname!='' && name!='' && bod!='' && mobile!='' && email!='' &&  inst_name!='' && edu_period!='' && edu_spec!='' && family!='' && edu_level!='' && captcha==captcha_sum){
        $("input[name=reg_but]").removeAttr("disabled");
        $("input[name=yesno]").val('y');
        return true;
    }else{
        $("input[name=reg_but]").attr("disabled","disabled");
        $("input[name=yesno]").val('n');
        return false;
    }
}

