Jquery关注并验证php项目上未运行的数据

Jquery关注并验证php项目上未运行的数据,php,jquery,Php,Jquery,我有一个php项目和一些php文件。 我正在尝试用jquery验证表单数据,但它不起作用。 这是我的密码。该文件是index.php。 我想在单击时清除文本输入,并用文本和空格验证输入文本。谢谢 <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools |

我有一个php项目和一些php文件。 我正在尝试用jquery验证表单数据,但它不起作用。 这是我的密码。该文件是index.php。 我想在单击时清除文本输入,并用文本和空格验证输入文本。谢谢

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
    <meta charset="UTF-8">
    <title>Criar</title>
    <link href="CSS_Menu.css" rel="stylesheet" type="text/css"/>
    <script src="JS/jquery.js" type="text/javascript"></script>
</head>
<body>
    <?php
    include 'menu.php';
    ?>
    <h1>Criar novo registo</h1>

    <form class="criar">
        <label class="criar">Nome</label>
        <input type="text" id="input_nome" name="nome" value="Insira">
        <br>
        <label class="criar">Apelido</label>
        <input type="text" id="input_apelido" name="apelido" value="Insira">
        <br>
        <label class="criar">Telefone</label>
        <input type="texto" id="input_telefone" name="tele" value="Insira">
        <br>
        <label class="criar">Email</label>
        <input type="text" id="input_email" name="email">
        <br>
        <br>
        <input type="submit" id="botao" name="criar" value="Criar">
    </form>
    <script>
        $(document).ready(function(){

         $("#input_nome").focusin(function()){
            $(this).value=' ';   
         });


        $("#input_nome").focusout(function(){

            var v=$("#input_name").val();
            var l=$("#input_name").val().length;
            var regex= /^[\S][\w\]+$/;
            if (v.match(regex)){
                window.alert("Got it");
            }
        });
     });
    </script>
</body>
</html>

叫喊
新登记处
诺姆

阿皮利多
电传
电子邮件

$(文档).ready(函数(){ $(“#输入名称”).focusin(函数()){ $(此).value=''; }); $(“#输入名称”).focusout(函数(){ var v=$(“#输入#u名称”).val(); var l=$(“#输入_名称”).val().length; var regex=/^[\S][\w\]+$/; if(v.match(regex)){ window.alert(“明白了”); } }); });
对于测试,我在document ready函数之后放置了一个console.log,它可以正常工作。 所以现在我猜代码一定出了问题。 谢谢你的帮助。
我将对此进行更深入的研究。

要清空输入,请将其更改为
$(this)
$(this.val(“”)在focusout验证中,您想做什么?在focusout中,我想检查是一个空格,然后是任何单词,如果是,则制作一个窗口警报,说“收到了”。我之前已经更改了它,dindt工作了。您想检查它是否以空格字符(“”)开头吗?