// Encoding: UTF-8 "use strict"; //This will execute when your page is loaded var allowSubmit = false; $(function(){ //Required attribute fallback var form = $("form "); form.submit(function() { // detect Safari browser var is_safari = navigator.userAgent.indexOf("Safari") > -1; var is_Opera = navigator.userAgent.indexOf("OPR") > -1; if (( navigator.userAgent.indexOf('Chrome') > -1 )&&(is_safari)) {is_safari=false;} if (is_safari || is_Opera) { //If required attribute is not supported or browser is Safari (Safari thinks that it has this attribute, but it does not work), then check all fields that has required attribute ($('input,textarea,select').filter('[required]')).each(function() { if (!$(this).val()) { //If at least one required value is empty, then ask to fill all required fields. alert("Please fill all required fields."); return false; } }); } return verify_form(); }); }); function capcha_filled () { allowSubmit = true; } function capcha_expired () { allowSubmit = false; } function check_if_capcha_is_filled () { if(allowSubmit) return true; alert("Captcha must be filled"); return false; } /** *verify_form *verify if the login exists *@param boolean */ function verify_form(){ if (check_if_capcha_is_filled()) { return true; }else { return false; } }