Jquery does not work in PHP

Asked

Viewed 1,559 times

0

I don’t know why. The page doesn’t work. Does anyone know how to help me figure out the problem? I want the date mask to work in the fields data and in the field Venc_Garantia

someone can help me?

<html>
<head>
<script src="C:\wamp\www\cadastro\javascript\jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="C:\wamp\www\cadastro\javascript\jquery.maskedinput.min.js" type="text/javascript"></script>

<script>
jQuery(function($){
$("#data").mask("99/99/9999",{placeholder:" "});
$("#venc_garantia").mask("99/99/9999",{placeholder:" "});
});
</script>

<title></title>
</head>
Caso NAO seja DELL clicar aqui: <input name="cadastro_dell" type="button" 
onClick="location.href='http://localhost/cadastro/cadastro.php'" value="Cadastro DELL">
<body>
<form name="signup" method="post" action="cadastrando_dell.php"> <br /><br />
Fabricante: <input type="text" name="fabricante" maxlength="10" /> <br /><br />
Modelo: <input type="text" name="modelo" maxlength="50" /> <br /><br />
Tipo: <input type="text" name="tipo" maxlength="50"/> <br /><br />
Data de Envio(ano-mes-dia): <input type="text" name="data" id="data"/> <br /><br />
URL DELL: <input type="text" name="url" maxlength="100"/> <br /><br />
Numero de serie: <input type="text" name="serie" maxlength="12"/> <br /><br />
Proprietario: <input type="text" name="proprietario" maxlength="30"/> <br /><br />
Origem: <input type="text" name="origem" maxlength="30"/> <br /><br />
Venc. Garantia(ano-mes-dia): <input type="text" name="venc_garantia"          id="venc_garantia"/>
Tipo de Instalacao: <input type="text" name="tipo_instalacao" maxlength="30"/> <br />               
Configuracao: <input type="text" name="configuracao" maxlength="150"/> <br /><br />
uname_a: <input type="text" name="uname_a" maxlength="100"/> <br /><br />
Instalacao: <input type="text" name="instalacao" maxlength="250"/> <br /><br />
Situacao (status): <input type="text" name="status" maxlength="15"/> <br /><br />
Servicos: <input type="text" name="servicos" maxlength="150"/> <br /><br />


Descricao: <input type="text" name="descricao" maxlength="150" /> <br /><br />
Quantidade: <input type="text" name="quantidade" maxlength="5"/> <br /><br />
Numero de Tombamento: <input type="text" name="tombamento" maxlength="13"/> <br /><br />
Local de Uso: <input type="text" name="local" maxlength="20"/> <br /><br />


<input type="submit" value="Cadastrar DELL" name="botao"/>



</form>

<?php

if(isset($_POST["botao"])){
    if(empty($tipo) || empty($tombamento) || empty($status)){
            echo "Preencha todos os campos!";           
    }
}
?>      

</body>

</html>

`

I am using WAMP with everything updated, but even referencing the Jquery file I do not see applied to mask, which may be?

  • Obviously I misunderstood the question

  • If you are using a server, you cannot point the address of the file through the local disk, it should be in a folder shared by apache, such as www and use the relative path, as in the responses below.

4 answers

4


In case you are running this page on a SERVIDOR you should reference javascript like this

<script src="/cadastro/javascript/jquery-1.5.2.min.js"></script>
<script src="/cadastro/javascript/jquery.maskedinput.min.js"></script>

The error probably happens because this javascript file reference becomes inaccessible on a server.

  • Man, I can’t thank you enough. The worst I looked at N tutorials on the Internet and everyone showed me codes half mouth and I doing everything as ordered and did not run. Now it was straight! THANK YOU VERY MUCH!!!

1

Friend, the error is in how you read the scripts, as your page is running on a WAMP server it does not access the files normally. From a glance at the browser error console by clicking inspect element in Chrome and then console, it probably returned two 404 errors and unknown function errors since the scripts were not loaded. Another tip is to load jquery-1.5.2.min. js straight from Google CDN, like this:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

1

Change the file paths

<script src="C:\wamp\www\cadastro\javascript\jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="C:\wamp\www\cadastro\javascript\jquery.maskedinput.min.js" type="text/javascript"></script>

for:

<script src="nome_da_pasta_ou_projeto/javascript/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="nome_da_pasta_ou_projeto/javascript/jquery.maskedinput.min.js" type="text/javascript"></script>

-3

It might work if you inform on the CRS something like:

<script src="file:///c:/myScript.js">
  • 2

    Welcome to [en.so]! Referencing the file by local path is not good practice and will not work in browsers with security enabled or when accessed from another computer. These are some of the reasons why his reply received negative votes. You can edit the answer and improve it or remove it to cancel the opposing votes. I also suggest you read on how to write a good answer in our Help Center. Hug!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.