From ca630cd1a3464bc665f06ade7c6e78efa27e93cb Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 17 Aug 2017 10:40:43 +0530 Subject: Change course.js to validate email form details --- yaksh/static/yaksh/js/course.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/yaksh/static/yaksh/js/course.js b/yaksh/static/yaksh/js/course.js index 74ad37c..0eeb017 100644 --- a/yaksh/static/yaksh/js/course.js +++ b/yaksh/static/yaksh/js/course.js @@ -43,37 +43,30 @@ $(function() { }) }); -var status; -var btn_name; - $("#send_mail").click(function(){ - btn_name = "send_mail"; var subject = $("#subject").val(); var body = $('#email_body').val(); + var status; if (subject == '' || body == ''){ status = false; - $("#error_msg").html("Please enter email details"); + $("#error_msg").html("Please enter mail details"); $("#dialog").dialog(); } else{ status = true; } + return status; }); $('#send_mail_form').submit(function(eventObj) { - if (btn_name == 'send_mail'){ - if(status == false){ - return false; - } - } var selected = []; $('#reject input:checked').each(function() { selected.push($(this).attr('value')); }); - if(selected.length > 0){ + if(selected.length > 0) { return true; } - else{ + else { $("#error_msg").html("Please select atleast one user"); $( "#dialog" ).dialog(); return false; -- cgit