toastr.clear(); toastr.options = { "closeButton": true, "debug": false, "newestOnTop": true, "progressBar": false, "positionClass": "toast-bottom-center", "preventDuplicates": true, "showDuration": "1000", "hideDuration": "10000", "timeOut": "2000", "extendedTimeOut": "1000" }; $(document).ready(function() { $("#st_regform").submit(function(){ var error = ""; $("#st_regform button[type='submit']").html('Please wait'); $("#st_regform button[type='submit']").attr("disabled","true"); $.ajax({ url: "https://fetadmission.jcdigits.in/register-action", type: "POST", dataType:"json", data: new FormData($("#st_regform")[0]), async: true, contentType: false, cache: false, processData:false, success: function(data) { toast_type = data.type; $("#st_regform button[type='submit']").html('Generate Verification Mail'); $("button[type='submit']").removeAttr("disabled"); if(data.type=="success") { window.location = "otp-verification"; } if(toast_type=='success') { toastr.success(''+data.text); } else { toastr.warning(''+data.text); } }, error: function(xhr, ajaxOptions, thrownError) { toastr.error(' Failed! Something is wrong.'); $("#st_regform button[type='submit']").html('Generate Verification Mail'); $("#st_regform button[type='submit']").removeAttr("disabled"); } }); return false; }); $('.allow_name').keypress(function (e) { validationForAllow_name(e); }); function validationForAllow_name(e){ var regex = new RegExp(/^([a-zA-Z\s])+$/); var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); if (regex.test(str)) { return true; } e.preventDefault(); return false; } $('.allow_name_number').keypress(function (e) { validationForAllow_name_number(e); }); function validationForAllow_name_number(e){ var regex = new RegExp(/^([a-zA-Z0-9])+$/); var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); if (regex.test(str)) { return true; } e.preventDefault(); return false; } $('.allow_name_number_schar').keypress(function (e) { validationForAllow_name_number_schar(e); }); function validationForAllow_name_number_schar(e){ var regex = new RegExp(/^[0-9a-zA-Z/-]+$/); var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); if (regex.test(str)) { return true; } e.preventDefault(); return false; } $('.allow_number').keypress(function (e) { validationForAllow_number(e); }); function validationForAllow_number(e){ var regex = new RegExp(/^[0-9]+$/); var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); if (regex.test(str)) { return true; } e.preventDefault(); return false; } // $(".allow_name").bind('keyup blur',function(){ // var node = $(this); // node.val(node.val().match(/^[a-zA-Z ]*$/) ); // }); // $(".allow_name_number").bind('keyup blur',function(){ // var node = $(this); // node.val(node.val().match(/^[a-zA-Z0-9]*$/) ); // }); // $(".allow_name_number_schar").bind('keyup blur',function(){ // var node = $(this); // node.val(node.val().match(/^[0-9a-zA-Z/ -]+$/) ); // }); // $(".allow_number").on('keydown',function(e){ // var node = $(this); // node.val(node.val().match(/^[0-9 ]+$/) ); // }); $('.allow_decimal').keypress(function (e) { validationForAllow_decimal(e); }); function validationForAllow_decimal(e){ var regex = new RegExp(/^[\d*\.?\d]+$/); var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); if (regex.test(str)) { return true; } e.preventDefault(); return false; } // $(".allow_decimal").on('keydown',function(e){ // var node = $(this); // node.val(node.val().match(/^\d*\.?\d*$/) ); // }); }); function validateEmail(email) { var email_val = $("#"+email).val(); var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; if(regex.test(email_val)) { //return false; } else{ $("#"+email).val(''); $("#"+email).focus(); toastr.warning(' Invalid Email ID'); } } function validatePhone(phone) { var phone_val = $("#"+phone).val(); var regex = /^[0-9]{10}$/; if(regex.test(phone_val)) { //return false; } else{ $("#"+phone).val(''); $("#"+phone).focus(); toastr.warning(' Invalid Phone No'); } } // For Validation minimum char in hs-registration function validateaadhaar_no(aadhaar_no) { var aadhaar_no_val = $("#"+aadhaar_no).val(); var regex = /^([0-9a-zA-Z/ -]){12,12}$/; if(regex.test(aadhaar_no_val)) { //return false; } else{ $("#"+aadhaar_no).val(''); $("#"+aadhaar_no).focus(); toastr.warning(' Invalid aadhaar no. Enter 12 digit no'); } } // For Validation minimum char in First-Name function validateFname(fname) { var fname_val = $("#"+fname).val(); var regex = /^([a-zA-Z\s]){1,50}$/; if(regex.test(fname_val)) { //return false; } else{ $("#"+fname).val(''); $("#"+fname).focus(); toastr.warning(' Invalid Firse Name. Enter Minimum 2 and Maximum 50 Charecters'); } } // For Validation minimum char in First-Name function validateMname(mname) { var mname_val = $("#"+mname).val(); var regex = /^([a-zA-Z]){2,24}$/; if(regex.test(mname_val)) { //return false; } else{ $("#"+mname).val(''); $("#"+mname).focus(); toastr.warning(' Invalid Middle Name. Enter Minimum 2 and Maximum 24 Charecters'); } } // For Validation minimum char in Last-Name function validateLname(lname) { var lname_val = $("#"+lname).val(); var regex = /^([a-zA-Z\s]){1,50}$/; if(regex.test(lname_val)) { //return false; } else{ $("#"+lname).val(''); $("#"+lname).focus(); toastr.warning(' Invalid Last Name. Enter Minimum 2 and Maximum 50 Characters'); } } // For Validation minimum char in Last-Name function validatePassword(password) { var password_val = $("#"+password).val(); var regex = /^([0-9a-zA-Z/#?!@$%^&*-+]){4,30}$/; if(regex.test(password_val)) { //return false; } else{ $("#"+password).val(''); $("#"+password).focus(); toastr.warning(' Invalid Password. Enter minimum 4 and maximum 30 characters'); } } function validateConfirm_password(confirm_password) { var confirm_password_val = $("#"+confirm_password).val(); var regex = /^([0-9a-zA-Z/#?!@$%^&*-+]){4,30}$/; if(regex.test(confirm_password_val)) { //return false; } else{ $("#"+confirm_password).val(''); $("#"+confirm_password).focus(); toastr.warning(' Invalid Confirm Password. Enter minimum 4 and maximum 30 characters'); } }