gpt4 book ai didi

javascript - JS : Javascript validation not working

转载 作者:行者123 更新时间:2023-11-29 19:02:26 24 4
gpt4 key购买 nike

Here is js fiddle

我已经做了很多验证,但这次没有工作我不知道如何请帮助我..HTML

<form action="" method="post" name="contactformm" onsubmit="return valiadd()">
<div class='row'>
<div class='col-sm-4'>
<div class='form-group'>
<label for='fname'>Name</label>
<input type='text' name='namee' class='form-control' />
</div>

<div class='text-right'>
<input type='submit' class='btn btn-primary' value='Submit' />
</div>
</div>
</div>
</form>

Javascript 代码

function valiadd {
var name = document.contactformm.namee.value;
if(name==""){
alert('Please Fill Your Name');
document.contactformm.namee.focus();
return false;
}

else {
return true;
}

}

最佳答案

你只是忘了在你的函数名后面加括号

只需更改这一行:

function valiadd {

function valiadd() {

关于javascript - JS : Javascript validation not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45859799/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com