Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only on Chrome I got this error: Uncaught TypeError: Illegal constructor [closed]

When I did load jQuery on Chrome I will receive this error: "Uncaught TypeError: Illegal constructor"

On rest browsers (IE, Mozilla) it's working fine. Here is couple screen shots from my PC. It's a same error.

first example
(source: vaziuoju.lt)

second example

Code:

$(Document).ready (function () {

    $("p.warning").hide();

    $( "#newAdsForm" ).submit(function( event ) {


        var vailidEmail = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

        var vardas = $("#vardas").val();                    var vardasTest = false;
        var vardas = vardas.replace(/<(?:.|\n)*?>/gm, '');
        var pastas = $("#pastas").val();                    var pastasTest = false;
        var phone = $("#phone").val();                      var phoneTest = false;
        var kada = $("#inputField").val();                  var kadaTest = false;
        var kaina = $("#kaina").val();                      var kainaTest = false;
        var kaina = kaina.replace(/<(?:.|\n)*?>/gm, '');
        var skelbimas = $("#skelbimas").val();              var skelbimasTest = false;
        var skelbimas = skelbimas.replace(/<(?:.|\n)*?>/gm, '');

        if (vardas == "") {
            $("p#vardas").fadeOut("fast", function () {
                $("p#vardas").text ("Vardas būtinas!");
            });
            $("p#vardas").fadeIn("fast");
            vardasTest = false;
        } else {
            $("p#vardas").fadeOut("fast");
            vardasTest = true;
        }

        if (pastas == "") {
            $("p#pastas").fadeOut("fast", function () {
                $("p#pastas").text ("El. paštas būtinas!");
            });
            $("p#pastas").fadeIn("fast");
            pastasTest = false;
        } else if (!pastas.match(vailidEmail)) {
            $("p#pastas").fadeOut("fast", function () {
                $("p#pastas").text("Negaliojantis pašto adresas!");
            });
            $("p#pastas").fadeIn("fast");
            pastasTest = false;
        } else {
            $("p#pastas").fadeOut("fast");
            pastasTest = true;
        }

        if (phone == "") {
            $("p#phone").fadeOut("fast", function () {
                $("p#phone").text ("Telefono numeris būtinas!");
            });
            $("p#phone").fadeIn("fast");
            phoneTest = false;
        }
        else if (!phone.match(/^[0-9-+]+$/)) {
            $("p#phone").fadeOut("fast", function () {
                $("p#phone").text ("Neteisingas Telefono numeris!");
            });
            $("p#phone").fadeIn("fast");
            phoneTest = false;
        } else  {
            $("p#phone").fadeOut("fast");
            phoneTest = true;
        }

        var comp = kada.split('-');
        if ((comp[0].length != 4) || (comp[1].length != 2) || (comp[2].length != 2) || (kada.length != 10)) {
            $("p#kada").fadeOut("fast", function () {
                $("p#kada").text ("Blogai nurodyta data!");
            });
            $("p#kada").fadeIn("fast");
            kadaTest = false;
        } else if ((!comp[0].match(/^\d+$/)) || (!comp[1].match(/^\d+$/)) || (!comp[2].match(/^\d+$/))) {
            $("p#kada").fadeOut("fast", function () {
                $("p#kada").text ("Blogai nurodyta data2!");
            });
            $("p#kada").fadeIn("fast");
            kadaTest = false;
        } else {
            $("p#kada").fadeOut("fast");
            kadaTest = true;
        }

        if (kaina.length != 0) {


            var number = /^\-{0,1}(?:[0-9]+){0,1}(?:\.[0-9]+){0,1}$/i;
            var regex = RegExp(number);

            if (!regex.test(input) && input.length>0) {
                $("p#kaina").fadeOut("fast", function () {
                    $("p#kaina").text ("Neteisinga kaina!");
                });
                $("p#kaina").fadeIn("fast");
                kainaTest = false;
            } else {
                $("p#kaina").fadeOut("fast");
                kainaTest = true;
            } 
        } else {
            $("p#kaina").fadeOut("fast");
            kainaTest = true;
        } 

        if (vardasTest && pastasTest && phoneTest && kadaTest && kainaTest) return true;
        else return false;

    });

});

Part of HTML code

   <tr><td>Vardas</td><td><input type = "text" class = "newAdd" name = "vardas" id = "vardas" <?php if (isset($_SESSION ['vardas'])) echo "value = '".$_SESSION ['vardas']; ?>'/><p class = "warning" id = "vardas">Vardas būtinas!</p></td></tr>

Any ideas how I can fix it?

like image 217
Robertas Uldukis Avatar asked Nov 04 '13 23:11

Robertas Uldukis


1 Answers

You should try it with a lowercase

"d"

$(document).ready(function(){... 

javascript is case-sensitive once a variable is set

like image 111
john Smith Avatar answered Sep 20 '22 15:09

john Smith