@Caspergreen

Почему не работает jquery в safari на iphone?

Здравствуйте, имеется код
spoiler

$(function () {

            checkFormorder();


            $('.cash, .payme').bind('click', function (e) {


                $('#paymentype').val($(this).data('val'));
                console.log($('#paymentype').val($(this).data('val')));

                $('.payment-method__btn a.active').removeClass('active');

                $(this).addClass('active');


                return false;

            });

            $('.cash, #click').bind('click', function (e) {

                $('#paymentype').val($(this).data('val'));

                $('.payment-method__btn a.active').removeClass('active');

                $(this).addClass('active');

                return false;

            });

            $('#name, #phone').each(function () {
                if ($(this).val()) {
                    $(this).siblings('label').hide();
                }
            })

            $('#other').bind('keyup change', function () {

                $('#myaddr').val($(this).val()).trigger('change').change();

            });


            $(document).on('change', '.addrselect', function (e) {

                if ($(this).val() == 'hide' || $(this).val() == 'other') {
                    $('#myaddr').val('').trigger('change').change();

                    $('#other').val('');

                    $('#other').siblings('label').show();

                    $('#textarea').val('').trigger('chage').change();

                    $('#textarea').siblings('label').show();

                    checkFormorder();

                } else {

                    var val = ($(this).val()).split('---|||---');

                    $('#myaddr').val(val[0]);

                    if (val.length > 1) {

                        $('#textarea').val(val[1]).trigger('chage').change();

                        checkFormorder();

                        //$('#textarea').siblings('label').hide();

                    }

                }

            });


            $('#authform input').bind('keyup change', function () {

                if ($(this).attr('id') == 'phone_switch') {

                    if ($(this).val().length >= 11) {

                        $('#getcode_switch').show();

                    } else {

                        $('#getcode_switch').hide();

                    }

                    $('#code_switch').prop('disabled', false);

                    $('#phone_switch').prop('disabled', false);


                    $('#codecorrect_switch').hide();

                    $('#code_switch').val('');
                    $('#code_switch').siblings('label').show();

                }

                if ($(this).attr('id') == 'code_switch' && $(this).val().length == 4) {
                    if (!$('#code_switch').is(':disabled')) {

                        $('#code_switch').prop('disabled', true);

                        $('#phone_switch').prop('disabled', true);

                        $('#codeerror_switch').hide();

                        $('#codecorrect_switch').hide();


                        $.post('/', {

                            'cataction': 'checkcode',

                            'catis': 'auth',

                            'code': $('#code_switch').val()

                        }, function (data) {
                            $('#code_switch').prop('disabled', false);
                            $('#phone_switch').prop('disabled', false);


                            if (data != '') {

                                data = $.parseJSON(data);

                                if (data.error) {

                                    if (data.type == '1') {

                                        $('#codeerror_switch').show();

                                    } else {

                                        $('#code_switch').val('');
                                        $('#code_switch').siblings('label').show();

                                        $('#getcode_switch').show();

                                    }

                                } else {

                                    $('#codecorrect_switch').show();

                                    $('#code_switch').val('');
                                    $('#code_switch').siblings('label').show();

                                    $('#enterbut').prop('disabled', false);

                                }

                            }

                        });

                    }

                }

            });


            $(document).on('change keyup', '#orderfield input', function () {

                if ($(this).attr('id') == 'phone') {

                    if ($(this).val() != $(this).data('phone')) {

                        if ($(this).val().length >= 11) {

                            $('#getcode').show();

                        } else {

                            $('#getcode').hide();

                        }

                        $('#code').prop('disabled', false);

                        $('#phone').prop('disabled', false);


                        $('#codecorrect').hide();

                        //$('#entercode').hide();

                        $('#code').val('');
                        $('#entercode label').show();

                        $('#conf').val(0);

                    } else {

                        $('#code').prop('disabled', false);

                        $('#phone').prop('disabled', false);

                        $('#entercode').removeClass('error');

                        $('#conf').val(1);

                        $('#codecorrect').show();

                        $('#entercode').hide();

                        $('#getcode').hide();

                    }

                }


                if ($(this).attr('id') == 'code' && $(this).val().length == 4) {

                    if (!$('#code').is(':disabled')) {

                        $('#code').prop('disabled', true);

                        $('#phone').prop('disabled', true);


                        $('#entercode').removeClass('error');


                        $('#codecorrect').hide();

                        $('#conf').val(0);

                        //$('#enterbut').hide();


                        $.post('/', {

                            'cataction': 'checkcode',

                            'catis': 'auth',

                            'code': $('#code').val()

                        }, function (data) {

                            //console.log(data);

                            $('#code').prop('disabled', false);

                            $('#phone').prop('disabled', false);


                            data = $.parseJSON(data);

                            if (data.error) {

                                if (data.type == '1') {

                                    $('#entercode').addClass('error')

                                } else {

                                    $('#entercode').hide();

                                    $('#code').val('');
                                    $('#entercode label').show();

                                    $('#getcode').show();

                                }

                            } else {

                                $('#codecorrect').show();


                                $('#entercode').hide();

                                $('#code').val('');
                                $('#entercode label').show();

                                $('#conf').val(1);

                                //$('#enterbut').show();

                            }

                            //$('#enterbut').hide();

                        });

                    }

                }


                checkFormorder();

            });


            $('#getcode').bind('click', function () {

                $('#getcode').hide();

                $('#entercode').show();


                $.post('/', {

                    'cataction': 'getcode',

                    'phone': $('#phone').val()

                }, function (data) {
                });

                return false;

            });

            $('#getcode_switch').bind('click', function () {

                $('#getcode_switch').hide();

                $.post('/', {

                    'cataction': 'getcode',

                    'phone': $('#phone_switch').val()

                }, function (data) {
                });

                return false;

            });

        });

        function checkFormorder() {

            var name = $('#name').val(),

                phone = $('#phone').val(),

                phonee = $('#phone').data('phone'),

                conf = $('#conf').val(),

                addr = $('#myaddr').val(),

                text = $('#textarea').val(),

                check = $('#checkbox').is(':checked'),

                error = false;

            if (!name || !addr || !phone || !text
                || !check
                || (phone != phonee && conf == '0')

            ) {

                error = true;

            }
            setButton(error);
        }

        function setButton(error) {
            if (!error) {
                $('#orderbu').prop('disabled', false);

            } else {
                $('#orderbu').prop('disabled', true);
            }
        }


Почему при заполнении формы не отрабатывает js?
  • Вопрос задан
  • 215 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы