我有ASP.NET项目,我需要检查电子邮件是否正确.我总是使用那个脚本,但它失败了asp.net,因为它@
是坏符号.
function emailvalidate(e)
{
var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
return b.test(e);
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?通过JavaScript检查电子邮件非常重要,而不是ASP.NET或C#.
PS我是ASP.NET和JavaScript RegEx的新手.
我试过这么多npm包来验证邮箱地址和域名。这是我尝试过的一些 npm 包
email-check,
email-verify,
email-existence,
legit,
email-validator and,
email validation
Run Code Online (Sandbox Code Playgroud)
所有这些只会导致域名存在和其他一些检查。但我必须验证域中存在的特定电子邮件地址。我应该如何实现这一点...... 任何人都可以帮我找到它 提前谢谢!
我有很多带有这种模式的字符串
/ucwa/oauth/v1/applications/101507538841/people/adan.maddox@dc.com/presence
我如何使用正则表达式来获取电子邮件 adan.maddox@dc.com
我尝试了这个代码,它的工作,但我觉得这不是一个好方法.
var y = myString.substring(0, myString.lastIndexOf("/presence"));
var email = y.substring(y.lastIndexOf("people/") + 7);
Run Code Online (Sandbox Code Playgroud) 如何使用JavaScript验证电子邮件。我有click事件,用于检查该值是否为空-请参阅下文,但如何在检查正则表达式的单独函数中检查onblur事件
var e =document.forms["myForm"]["email_18"].value;
if(e==null ||e=="" || e=="someone@example.com")
{
document.getElementById("emailMessage").innerHTML = "*Please enter an email";
flag = false;
}
Run Code Online (Sandbox Code Playgroud)
文本框:
<input type="email" class="text" name="email_18" id="amf-input-email_18" value="" placeholder="someone@example.com" maxlength="255" onkeyup="if(this.length>255) this.value=this.value.substr(0, 255)"></div></div>
Run Code Online (Sandbox Code Playgroud) 我正在使用引导验证程序,但电子邮件字段接受“test@test”。你可以在我的链接上尝试一下。我该如何解决这个问题?使用模式属性,我可以编写正则表达式,但我不知道这样做。
我已经尝试过这个正则表达式,但所有电子邮件都不正确:
<?php
echo $this->tag->emailField(
array(
"email",
"class" => "form-control",
"data-error" => "incorrect address",
"pattern" => '/^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i',
"required" => "required"
)
);
?>
Run Code Online (Sandbox Code Playgroud) 我已经创建了一个注册表单。因为电子邮件验证不起作用!
这是代码:-
HTML页面
<form [formGroup]="myForm" (ngSubmit)="submit()" >
<ion-item>
<ion-label primary floating>EMAIL</ion-label>
<ion-input type="email" id="email" class="form-control" formControlName="email" ></ion-input>
</ion-item>
<p *ngIf="myForm.controls.email.errors && myForm.controls.email.dirty " class="alert alert-danger">
<small class="up"> <i>Enter Valid Email Address!</i></small></p>
Run Code Online (Sandbox Code Playgroud)
ts文件:-
this.myForm = formBuilder.group({
'email' : new FormControl('', [Validators.required, Validators.pattern(required pattern=("^[a-zA-Z0–9_.+-]+@[a-zA-Z0–9-]+.[a-zA-Z0–9-.]+$)"])
}
Run Code Online (Sandbox Code Playgroud)
当我以表格形式输入一些数据时,它们将生效!!不验证电子邮件!
与何时可以检测具有required
属性的输入元素是否正确验证类似,编写以下代码:
if($('input').attr('required')) {
alert(1);
}
Run Code Online (Sandbox Code Playgroud)
如何检查输入type='email'
是否有效?
编辑:
我不是在问如何通过将输入与正则表达式进行比较来验证输入。
当您将输入类型属性设置为 'email' 时,提交的字符串必须具有正确的格式(它需要包含 '@' 符号并具有正确的结尾),否则您将无法提交表单。我想要实现的是阻止表单提交的默认操作,并检查该电子邮件输入验证的状态,类似于何时可以检查是否提供了所需的输入。
我已经尝试解决这个问题将近一个小时了,如果没有任何帮助或解释,我无法看到自己在这方面取得更大进展。我以前使用过正则表达式,但只使用了非常简单或已经制作的正则表达式。
这一次,我试图弄清楚如何编写一个实现以下目标的正则表达式:
电子邮件地址必须包含一个@ 字符和至少一个点 (.),@ 字符后至少一个位置。
到目前为止,这就是我所能解决的所有问题,它仍然可以匹配具有多个 @ 符号的电子邮件地址。
.*?@?[^@]*\.+.*
如果您能向我展示如何构造一个正则表达式来检查单个 @ 和至少一个句号,那将很有帮助 @ 之后的一个或多个空格。如果您可以分解正则表达式并解释每个位的作用,那将非常有帮助。
我现在想保持简单,所以它不必是一个完整的超级准确的电子邮件验证表达式。
提到这个问题:
<form id="new_invitation" class="new_invitation" method="post" data-remote="true" action="/invitations" accept-charset="UTF-8">
<div id="invitation_form_recipients">
<input type="text" value="" name="invitation[recipients][]" id="invitation_recipients_0"><br>
<input type="text" value="" name="invitation[recipients][]" id="invitation_recipients_1"><br>
<input type="text" value="" name="invitation[recipients][]" id="invitation_recipients_2"><br>
<input type="text" value="" name="invitation[recipients][]" id="invitation_recipients_3"><br>
</div>
<input type="submit" value="Send invitation" name="commit">
</form>
Run Code Online (Sandbox Code Playgroud)
使用jquery为字段设置最小长度的代码?
$('#new_invitation').submit(function(event) {
if ($('#invitation_form_recipients input').filter(function() {
return $(this).val();
}).length == 0) {
// all the fields are empty
// show error message here
// this blocks the form from submitting
event.preventDefault();
}
});
Run Code Online (Sandbox Code Playgroud)
如何验证每个字段输入是否具有jquery的有效电子邮件地址?在上面的代码?
谢谢!
$('#new_invitation').submit(function(e) {
$('#invitation_form_recipients input').each(function(e) { …
Run Code Online (Sandbox Code Playgroud) 我正在使用正则表达式来验证JavaScript中的电子邮件地址.
正则表达式非常简单.它检查三件事:1)'@',2)'.' ('dot'在something@gmail.com中),以及3)电子邮件地址中的'az'.如果所有三个都返回true,则电子邮件地址有效(根据我的验证,至少)
这是代码:
function checkemail(){
var e = document.getElementById("email").value;
if((e.match(/@/g)==null)||(e.match(/[a-z]/ig)==null)||(e.match(/./g)==null)){
//display error message
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:
(e.match(/./g)==null); //returns false even though there are no dots in the string e
Run Code Online (Sandbox Code Playgroud)
即使字符串中没有点,也会返回false.
例如:
("thisIsMyEmail".match(/./ig))==null //returns false
Run Code Online (Sandbox Code Playgroud)
如果它应该是真的,为什么它会返回false?
在TextInput中输入电子邮件时,它应根据输入的电子邮件是否有效来验证并显示错误消息?我正在使用tcomb表单验证.如何以tcomb形式添加电子邮件验证?下面是代码.
import React, { Component } from 'react';
import {
AppRegistry,
Text,
Image,
View,
Button,
StyleSheet,
TextInput,
Linking,
Alert,
Navigator
} from 'react-native';
import t from 'tcomb-form-native';
const Form = t.form.Form;
// here we are: define your domain model
const LoginFields = t.struct({
username: t.String, // a required string
password: t.String, // a required string
});
const options = {
fields: {
password: {
type: 'password',
placeholder: 'Password',
},
username: {
placeholder: 'e.g: abc@gmail.com',
error: 'Insert a valid email'
} …
Run Code Online (Sandbox Code Playgroud) 我如何在没有表单的情况下验证电子邮件地址是否具有@符号和点而无需按下按钮。我将不胜感激任何帮助。
<mat-form-field class="example-full-width">
<input matInput placeholder="Favorite food" value="Sushi">
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
javascript ×7
regex ×5
validation ×3
angular ×2
forms ×2
asp.net ×1
c# ×1
email ×1
html ×1
jquery ×1
node.js ×1
react-native ×1