Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在js中获得false as返回后停止php执行_Javascript_Php_Html - Fatal编程技术网

Javascript 如何在js中获得false as返回后停止php执行

Javascript 如何在js中获得false as返回后停止php执行,javascript,php,html,Javascript,Php,Html,我有一个带有js的phone no验证程序,它工作正常,但是eve在返回php代码时出错。如何阻止它执行 这是我的js函数 function phonenumber(inputtxt){ var phoneno = /^\d{10}$/; if(inputtxt.value.match(phoneno)) {return true;} else {alert("message"); return false;} } 这是我的html代码 <

我有一个带有js的phone no验证程序,它工作正常,但是eve在返回php代码时出错。如何阻止它执行

这是我的js函数

function phonenumber(inputtxt){
    var phoneno = /^\d{10}$/;
    if(inputtxt.value.match(phoneno))
    {return true;}
    else
    {alert("message");
     return false;}
}
这是我的html代码

<form action="get_quote.php" method="post" name="quote" class="quote">
                <font class="label"><input type="text" class="quote" placeholder="Enter Your Name" autocomplete="off" name="name" required/>
                <input type="text" class="quote" autocomplete="off" placeholder="Enter Your Mobile Number" name="mobile" required/>
                <input type="email" class="quote" autocomplete="off" placeholder="Enter Your Email Id" name="email" required/><br />
                    </center>
                <div>
                <div class="rest">
                    <input type="radio" id="new" name="condition" class="rest" checked>New<br />
                    <input type="radio" id="mod" name="condition" class="rest"/>Modification
                </div>
                <div class="rest">
                    <input type="checkbox" name="web"  />Website<br />
                    <input type="checkbox" name="android" />Android Application<br />
                    <input type="checkbox" name="ios" />IOS Aplication<br />
                    <input type="checkbox" name="seo" />SEO/SMO<br />
                    <input type="checkbox" name="desktop" />Computer Software<br />
                </div>
                </div>
                <br><center>
                <textarea name="desc" placeholder="Enter Your Description" required></textarea><br /></font>
                <button type="submit" onclick="phonenumber(document.quote.mobile)" class="quote">Get Quote</button>
            </form>


新的
修改 网站
Android应用程序
IOS应用程序
SEO/SMO
计算机软件


获得报价

在函数调用之前的
onclick
中添加
return

<button type="submit" onclick="return phonenumber(document.quote.mobile)" class="quote">Get Quote</button>
获取报价

希望这有帮助。

您可以使用以下方法获得移动字段值:

function phonenumber()
{ 
    var inputtxt = document.getElementsbyName("mobile");
    var phoneno = /^\d{10}$/;                 

    if(inputtxt.value.match(phoneno)) 
    {

        return true;
    } 
    else 
    {
        alert("message"); 
        return false;
    } 
} 
如果不需要在onclick事件中传递param,请使用以下命令:

<button type="submit" onclick="phonenumber()" class="quote">Get Quote</button>
获取报价

不客气,但应该可以检查我的更新中的小提琴。它再次不起作用不知道为什么。代码没有任何变化我想我的脚本在不同的php上,这就是为什么它会发生如果我没有给出参数,它甚至没有给出警告消息,是的,没有帮助anyway@sahib比chk控制台有没有发现任何错误?你也可以按照其他配偶的建议使用returnparam@sahib... 你也可以试试这个,我两个都试过了。如果我至少给出参数,我会收到警报消息,这至少意味着我会得到一个返回值,但在没有参数的情况下,我甚至不会收到警报message@sahib尝试在表单标记中添加onclick函数并从按钮中删除