javascript中必需的字段velidator [英] required field velidator in javascript
本文介绍了javascript中必需的字段velidator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在php中创建项目,并希望使用java脚本的用户名字段的velidator
解决方案
这样的东西。我想你明白了......
< < span class =code-leadattribute> script type = text / javascript >
function ValideInput(){
if ( document .getElementById(' name')。value = = ' '){
alert(' 请输入用户名!');
return false ;
} 其他 {
return 真跨度>;
}
}
< 表格 action = randompage onsubmit = 返回ValideInput(); >
< input id = name type = 文字 > < 输入 type = 提交 value = go >
< / form >
I make project in php and want velidator for username field using java script
解决方案
Something like this. I think you get the idea...
<script type="text/javascript">function ValideInput() { if(document.getElementById('name').value == '') { alert('Please enter a username!'); return false; }else{ return true; } }<form action="randompage" onsubmit="return ValideInput();"> <input id="name" type="text"><input type="submit" value="go"> </form>
这篇关于javascript中必需的字段velidator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文