㈠ js判斷郵箱格式
<script language=javascript>
<!--
function checkform() {
if(addform.yx.value != '') {
if(!Isyx(addform.yx.value)){
alert("請輸入正確的郵箱回地答址!")
addform.yx.focus();
return false;
}
}
}
function Isyx(yx){
var reyx= /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
return(reyx.test(yx));
}
//-->
</script>
㈡ JS判斷Email格式,請高手來給我解答一下,
<SCRIPT LANGUAGE="JavaScript">
<!--
function check()
{
if(document.form.email.value.length!=0)
{
if (document.form.email.value.charAt(0)=="." ||
document.form.email.value.charAt(0)=="@"||
document.form.email.value.indexOf('@', 0) == -1 ||
document.form.email.value.indexOf('.', 0) == -1 ||
document.form.email.value.lastIndexOf("@")==document.form.email.value.length-1 ||
document.form.email.value.lastIndexOf(".")==document.form.email.value.length-1)
{
alert("Email的格式不正確!");
document.form.email.focus();
return false;
}
}
else
{
alert("Email的不能為空!");
document.form.email.focus();
return false;
}
}
//-->
</SCRIPT>
<div id="apDiv2"><img src="image/天藍色主色調.JPG" width="956" height="35" /></div>
<div id="apDiv3">
<form id="form" name="form1" method="get" action="checkuser.asp" onsubmit="return check()">
這段代碼可以用,已測試!希望對你有幫助
㈢ 關於js想要正確的郵箱格式和電話格式
說實話,我很建議你去http://www.51js.com里看看。
不過我還是先給一些代碼吧:
1.關於密碼驗卜知圓證還存在漏洞:
應該是:if(form1.password.value==""||form1.password.length==0)
{
alert("密碼不能為空,請輸入密碼");
return false;
}
2.關於郵箱驗證
if(form1.email.value==""||form1.password.length==0)
{
alert("郵箱不能為空,請輸入地址");
return false;
}
if(form1.email.value.indexOf("@") <1||form1.email.value.lastIndexOf(".") )
{alert("郵箱格式型塌不猛顫正確");return false}
else {return true}
3.驗證電話號碼:
if(form1.tel.value=="")
{
alert("電話不能為空,請輸入號碼");
return false;
}
if(form1.tel.value>9||form1.tel.value<0){
alert("偶還沒見過英文字母的電話號碼")
return false;
}
㈣ 幫我用JS寫一個函數,判斷E-mail是否全合法,用正則表達式。
Stringregex=".+@.+(\..{2,3})*\..{2,3}";
Stringregex1="\w+@\w+(\.\w+)*\.\w+";
Stringregex3="\w+@\w+(\.\w{2,3})*\.\w{2,3}";
Strings37="aaaa";
Strings38="aaaa@";
Strings39="aaaa@qqqq";
Strings40="[email protected]";
Strings41="[email protected]";
if(s37.matches(regex)){
System.out.println(s37+"是合法的-mail地址");
}
if(s38.matches(regex)){
System.out.println(s38+"是合法的E-mail地址");
}
if(s39.matches(regex)){
System.out.println(s39+"是合法的E-mail地址");
}
if(s40.matches(regex)){
System.out.println(s40+"是合法的E-mail地址");
}
if(s41.matches(regex)){
System.out.println(s41+"是合法的E-mail地址");
}
(4)js驗證郵箱格式擴展閱讀
判斷一個字元串是否符合某種格式
if(Regex.IsMatch(subjectString,"xyz[1-8]")){
//Successfulmatch
}else{
//Matchattemptfailed
}
㈤ 如何用js判斷div中的文本框輸入內容是否為email,若不是會在文本框後顯示格式不正確
var email = $("#email").val();
if (!email.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)) {
$("#result").html("郵箱格式不枝拆正或搭轎衫肆確");
return false;
}
請採納
㈥ js怎麼校驗郵箱格式 並做到圖裡面的效果
用正則判斷,例子如下:
function isEmail(strEmail) {
if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
return true;
}else{
return false;
}
圖上的效果那就是樣式的問題了
格式錯誤時,輸入框獲取游標 xxx.focus(); ,改變輸入框顏色與背景色,右邊的提示是個層,默認為隱藏,錯誤時顯示
㈦ javascript驗證郵箱格式是否正確
是否正確的話可以通過正則表達式校驗,是否存在可以通過對存儲用戶信息的資料庫進行檢索來判斷。給你一個正則表達式的例子吧,是對Form內輸入框進行校驗的。
if(document.form1.mail.value=="")
{
alert("電子郵件不能為空");
return false;
}
else
{
reg=/^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi;
if(!reg.test(document.form1.mail.value))
{
alert("非法的電子郵件");
return false;
}
}
㈧ 使用JS和CSS如何判斷郵箱格式
<formaction="">
輸入:<inputtype="text"name="mazey"id="mazey"placeholder="請輸入郵箱">
<inputtype="button"value="驗證"onclick="check();">
</form>
<script>
functioncheck(){
varreg=newRegExp("^[a-z0-9]+([._\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");//正則表達式
varobj=document.getElementById("mazey");//要驗證的對象
if(obj.value===""){//輸入不能為空
alert("輸入不能為空!");
returnfalse;
}elseif(!reg.test(obj.value)){//正則驗證不通過,格式不對
alert("驗證不通過!");
returnfalse;
}else{
alert("通過!");
returntrue;
}
}
</script>
㈨ js表單驗證:字數驗證、郵箱格式、字母開頭,重復密碼
<html>
<head>
<script type="text/javascript">
function validate()
{
var ok=true,un,pw1,pw2,el,ch0;
var r = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
if(""==(un=document.f.user.value))
{
alert("用戶名不能為空!");
document.f.user.focus();
ok=false;
}
else if(""==(pw1=document.f.password1.value))
{
alert("密碼不能為空!");
document.f.password1.focus();
ok=false;
}
else if(""==(pw2=document.f.password2.value))
{
alert("重復密碼不能為空!");
document.f.password2.focus();
ok=false;
}
else if(""==(el=document.f.email.value))
{
alert("郵箱不能為空!");
document.f.email.focus();
ok=false;
}
if(ok)
{
if(!(un.length>=6 && un.length<=20))
{
alert("用戶名長度必須大於等於小於等於20!");
document.f.user.focus();
ok=false;
}
else
{
ch0=un.charAt(0).toLowerCase();
if(!(ch0>="a" && ch0<="z"))
{
alert("用戶名必須以字母開頭!");
document.f.user.focus();
ok=false;
}
else if(pw1!=pw2)
{
alert("重復密碼與密碼必須相同!");
document.f.password2.focus();
ok=false;
}
else if(!r.test(el))
{
alert("不是有效的郵箱地址!");
document.f.email.focus();
ok=false;
}
}
}
if(ok)
{
alert("恭喜你,通過了有效性驗證!");
}
}
</script>
</head>
<body>
<form name="f">
用戶名:<input type="text" name="user" /><br /><br />
密碼:<input type="text" name="password1" /><br /><br />
重復密碼:<input type="text" name="password2" /><br /><br />
郵箱:<input type="text" name="email" /><br /><br />
<input type="button" value="驗證" onclick="validate();" />
</form>
</body>
</html>
㈩ JS 驗證郵箱的問題
|function checkemail(){
var temp = document.getElementById("tbEmail");
//對電子郵件的驗證
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if(temp.value!=""){
if(!myreg.test(temp.value)){
alert('提示:請輸入有效的E_mail!回');
tbEmail.focus();
return false;}}}
</script>
郵箱答:<input type="text" runat="server" id="tbEmail" name="tbEmail" onBlur="checkemail();"/>可參考