1

アクションを完全に正しいボタンに入力タイプを与え、jqueryまたはjscriptでフォームを送信している間、私のフォームは送信されません。この問題を解決する方法はありますか?

私のコードは次のとおりです。

$(document).ready(function(){
$(".sumbitbtn").click(function(e) {

    var regEmail = new RegExp(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/);
    var selection       = document.myfrm.user_type;
    var lawfirm_name    =   $('#lawfirm_name').val();
    var first_name      =   $('#first_name').val();
    var last_name       =   $('#last_name').val();
    var mobile_no       =   $('#mobile_no').val();
    var email_id        =   $('#email_id').val();
    var practice_area   =   $('#practice_area').val();
    var cvalue          =   $('#authentication').val();


    var arr_msg         = Array();
    var count           = arr_msg.length;
    var alreadyFocussed = false;
    //alert(time1);
    //alert(start_date);
    if(selection[1].checked == true)
    {
    if(lawfirm_name=='')
    {
        $("#error_lawfirm_name").html('Please enter Lawfirm Name!');

        if(!alreadyFocussed){
            $('#lawfirm_name').focus();
            alreadyFocussed = true;
        }
        count++;
    }else{
        $("#error_lawfirm_name").html("");
    }
    if(!$("#lawfirm_name").val() == "") 
    {
        if(!NotNumeric($("#lawfirm_name").val()))
        {
            $("#error_lawfirm_name").html("Please Enter only character.");
            if(!alreadyFocussed){
                $('#lawfirm_name').focus();
                alreadyFocussed = true;
            }
            count++;
        }
        else
        {
            $("#error_lawfirm_name").html("");
        }
    }
    if(!$("#lawfirm_name").val() == "")
    {
        var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

         for (var i = 0; i < document.getElementById("lawfirm_name").value.length; i++)
         {
                if (iChars.indexOf(document.getElementById("lawfirm_name").value.charAt(i)) != -1) 
                {
                    $("#error_lawfirm_name").html("Your name has special characters. \nThese are not allowed.\n Please remove them and try again.");
                    if(!alreadyFocussed){
                        $('#lawfirm_name').focus();
                        alreadyFocussed = true;
                    }
                    count++;
                }
                else
                {
                    //$("#error_lawfirm_name").html("");
                }
          }

    }
    }
    if(first_name=='')
    {
        $("#error_first_name").html('Please enter First Name!');

        if(!alreadyFocussed){
            $('#first_name').focus();
            alreadyFocussed = true;
        }
        count++;
    }else{
        $("#error_first_name").html("");
    }
    if(!$("#first_name").val() == "") 
    {
        if(!NotNumeric($("#first_name").val()))
        {
            $("#error_first_name").html("Please Enter only character.");
            if(!alreadyFocussed){
                $('#first_name').focus();
                alreadyFocussed = true;
            }
            count++;
        }
        else
        {
            $("#error_first_name").html("");
        }
    }
    if(!$("#first_name").val() == "")
    {
        var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

         for (var i = 0; i < document.getElementById("first_name").value.length; i++)
         {
                if (iChars.indexOf(document.getElementById("first_name").value.charAt(i)) != -1) 
                {
                    $("#error_first_name").html("Your name has special characters. \nThese are not allowed.\n Please remove them and try again.");
                    if(!alreadyFocussed){
                        $('#first_name').focus();
                        alreadyFocussed = true;
                    }
                    count++;
                }
                else
                {
                    //$("#error_first_name").html("");
                }
          }

    }
    if(last_name=='')
    {
        $("#error_last_name").html('Please enter last Name!');

        if(!alreadyFocussed){
                        $('#last_name').focus();
                        alreadyFocussed = true;
                    }
                    count++;
    }else{
        $("#error_last_name").html("");
    }
    if(!$("#last_name").val() == "") 
    {
        if(!NotNumeric($("#last_name").val()))
        {
            $("#error_last_name").html("Please Enter only character.");
            if(!alreadyFocussed){
                        $('#last_name').focus();
                        alreadyFocussed = true;
                    }
                    count++;
        }
        else
        {
            $("#error_last_name").html("");
        }
    }
    if(!$("#last_name").val() == "")
    {
        var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

         for (var i = 0; i < document.getElementById("last_name").value.length; i++)
         {
                if (iChars.indexOf(document.getElementById("last_name").value.charAt(i)) != -1) 
                {
                    $("#error_last_name").html("Your name has special characters. \nThese are not allowed.\n Please remove them and try again.");
                    if(!alreadyFocussed){
                        $('#last_name').focus();
                        alreadyFocussed = true;
                    }
                    count++;
                }
                else
                {
                    //$("#error_last_name").html("");
                }
          }

    }

    if(mobile_no=='')
    {
        $("#error_mobile_no").html('Please enter mobile number!');

        if(!alreadyFocussed){
                        $('#mobile_no').focus();
                        alreadyFocussed = true;
                    }
                    count++;
    }else{
        $("#error_mobile_no").html("");
    }
    if(mobile_no!='')
    {    
        if(mobile_no.length < 10)
        {
            $("#error_mobile_no").html('Please enter 10 digit mobile number!');
            if(!alreadyFocussed){
                        $('#mobile_no').focus();
                        alreadyFocussed = true;
                    }
                    count++;
        }else{
            $("#error_mobile_no").html("");
        }
    }

    if(email_id=='')
    {
        $("#error_email").html('Please enter email!');

        if(!alreadyFocussed){
                        $('#email_id').focus();
                        alreadyFocussed = true;
                    }
                    count++;
    }else {
        $("#error_email").html("");
    }
    if(email_id!=''){
        if(!regEmail.test(email_id)){
            $("#error_email").html('Please enter a valid email.');
            if(!alreadyFocussed){
                        $('#email_id').focus();
                        alreadyFocussed = true;
                    }
                    count++;
            }else {
                $("#error_email").html('');
            }   
    }


    if(selection[0].checked == true)
    {

    if(practice_area=='')
    {
        $("#error_practice_area").html('Please enter area of practice!');
        if(!alreadyFocussed){
                        $('#practice_area').focus();
                        alreadyFocussed = true;
                    }
                    count++;
    }else {
        $("#error_practice_area").html('');
    }
    }
    else {
        $("#error_practice_area").html('');
    }
    if($("#country").val()=='')
    {
        $("#error_country").html('Please select country!');

        if(!alreadyFocussed){
                        $('#country').focus();
                        alreadyFocussed = true;
                    }
                    count++;
    }else {
        $("#error_country").hide();
    }

    if($("#state").val()=='')
    {
        $("#error_state").html('Please enter town!');

        if(!alreadyFocussed){
                        $('#state').focus();
                        alreadyFocussed = true;
                    }
                    count++;
    }else {
        $("#error_state").hide();
    }
    if(!$("#state").val() == "") 
    {
        if(Numeric($("#state").val()))
        {
            $("#error_state").html("Please Enter only character.");
            if(!alreadyFocussed){
                        $('#state').focus();
                        alreadyFocussed = true;
                    }
                    count++;
        }
        else
        {
            $("#error_state").html("");
        }
    }
    if($("#district").val()=='')
    {
        $("#error_district").html('Please enter city!');

        if(!alreadyFocussed){
                        $('#district').focus();
                        alreadyFocussed = true;
                    }
                    count++;
    }else {
        $("#error_district").hide();
    }
    if(!$("#district").val() == "") 
    {
        if(Numeric($("#district").val()))
        {
            $("#error_district").html("Please Enter only character.");
            if(!alreadyFocussed){
                        $('#district').focus();
                        alreadyFocussed = true;
                    }
                    count++;
        }
        else
        {
            $("#error_district").html("");
        }
    }
    if($("#pincode").val()=='')
    {
        $("#error_pincode").html('Please enter pincode!');

        if(!alreadyFocussed){
                        $('#pincode').focus();
                        alreadyFocussed = true;
                    }
                    count++;
    }else {
        $("#error_pincode").hide();
    }
    /*if(cvalue=='')
    {
        document.getElementById('error_authentication').innerHTML='Please enter security code!';

        if(!alreadyFocussed){
                        document.getElementById('authentication').focus();
                        alreadyFocussed = true;
                    }
                    count++;
    }
    else{
            document.getElementById('error_authentication').innerHTML="";
        }
    if(cvalue!='')
    {
        var securitycode = document.getElementById('scode').value;
        if(securitycode==0)
        {
            document.getElementById('error_authentication').innerHTML='Please enter correct security code!';
            if(!alreadyFocussed){
                        document.getElementById('authentication').focus();
                        alreadyFocussed = true;
                    }
                    count++;
        }
        else{
            document.getElementById('error_authentication').innerHTML="";
        }
    }*/

    if(count == 0){
    $('#myfrm').submit();
        if(cvalue!='')
            {
                document.getElementById('error_authentication').innerHTML="";
                $.post("<?php echo APP_ROOT_URL; ?>checkcode.php", { val: cvalue }, function(data) { 

                    if(data == "0") 
                    { 
                        document.getElementById('error_authentication').innerHTML='Please enter correct security code!';
                        if(!alreadyFocussed){
                            document.getElementById('authentication').focus();
                            alreadyFocussed = true;
                        }
                        sleep(10);
                        return false;
                    }
                    else
                    {
                        $("#error_authentication").text('');


                    }
                });
                //return false;
                alert(document.getElementById('error_authentication').innerHTML);
                if(document.getElementById('error_authentication').innerHTML == '') { alert('testing true'); document.getElementById('myfrm').submit(); } else { alert('testing false'); return false; }
            }
            else
            {
                document.getElementById('error_authentication').innerHTML='Please enter security code!';
                if(!alreadyFocussed){
                    document.getElementById('authentication').focus();
                    alreadyFocussed = true;
                }
                return false;
            }

        //return true;
    }else{
        return false;
    }
});
});

function checkcode(valuecode)
 {
    var  dataString = 'val='+valuecode;
    $.ajax({
        type: "GET",
        url: "<?php echo APP_ROOT_URL; ?>checkcode.php",
        data: dataString,
        cache: false,
        success: function(value1)
            {
                document.getElementById('scode').value=value1;
                if(value1=='0')
                {
                    //alert('Please enter correct security code!');
                    document.getElementById('error`enter code here`_authentication').innerHTML='Please enter correct security code!';
                    document.getElementById('authentication').focus();
                    return false;               
                }else{
                        document.getElementById('error_authentication').innerHTML="";
                     }
            }
        });

html部分

<form name="myfrm" id="myfrm" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="button" id="mynewid" name="submit" value="Submit" class="sumbitbtn" /></div>
</form>

チェックして助けてください。前もって感謝します

4

1 に答える 1