使用javascript验证。 [英] validation using javascript.

查看:96
本文介绍了使用javascript验证。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我的网页上有


我有一个注册表格可以注册。



我需要在提交按钮单击时使用javascript验证这些文本框。



总共我有6个文本框,我需要使用Javascript在提交按钮上单击验证。







TxtUserName ----必填字段



TxtPassword ---必填字段



TxtEmailAddress ----必须是电子邮件地址,且必须是有效的test@test.com



TxtRetypeEmailAddress ---重新输入电子邮件地址必须是必填项并且必须是有效的test@test.com并且必须与第一个电子邮件地址相匹配



TxtLocation - 必填字段



TxtMobileNo ---必填提交且仅接受号码且仅限10位数。





最后,我有提交按钮。

提交按钮



请你能帮我吗我,如何使用javascript验证所有这些。



提前感谢.....

解决方案

参考此链接



http://www.w3schools。 com / js / js_form_validation.asp [ ^ ]





http:/ /www.tutorialspoint.com/javascript/javascript_form_validations.htm [ ^ ]


一些可以帮助你的链接



使用样本注册表单进行JavaScript表单验证 [ ^ ]



使用注册表单进行JavaScript字段级表单验证 [ ^ ] < br $>


简单登记表对于具有验证的员工 [ ^ ]



JavaScript:表单验证 [ ^ ]


 <  表格   名称  =  myForm    action   =  demo_form.asp    onsubmit   =  return validateForm()   方法  =  post  >  
名字:< input type = text name = fname >
< input type = submit value = 提交 >
< / form >



< script type =   text / javascript> 
function validateForm()
{
var x = document .forms [ myForm] [< span class =code-string> fname]。value;
if (x == null || x ==
{
alert( 必须填写名字);
return false ;
}
}
< / script>
< / head >


Hi frnds,

on my webpage i have a registration form to register.

I need to validate these textboxes using javascript on submit button click.

total i have 6 textboxes, i need to validate on submit button click using Javascript.



TxtUserName ---- Required field

TxtPassword --- Required Field

TxtEmailAddress ---- Email address must be Required and it must be Valid as test@test.com

TxtRetypeEmailAddress --- Retype Email address must be Required and it must be Valid as test@test.com & it must match the First Email Address

TxtLocation -- Required Field

TxtMobileNo --- Required Filed & only Numbers are accepted & only 10 digits.


and finally, i have submit button.
SUBMIT BUTTON

Please can you help me, how to validate all these using javascript.

thanks in advance.....

解决方案

refer this links

http://www.w3schools.com/js/js_form_validation.asp[^]


http://www.tutorialspoint.com/javascript/javascript_form_validations.htm[^]


some more links which may help you

JavaScript Form Validation using a Sample Registration Form [^]

JavaScript Field Level Form Validation using a registration form [^]

Simple Registration Form For Employee With Validation[^]

JavaScript: Form Validation[^]


<form name="myForm" action="demo_form.asp" onsubmit="return validateForm()" method="post">
First name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>


<script type="text/javascript">
function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
  {
  alert("First name must be filled out");
  return false;
  }
}
</script>
</head>


这篇关于使用javascript验证。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆