Email Regexp
Mar 10, 2006I am trying to find an email regexp but none seem to validate the following example:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@xx....xxx.xxxxxx.xx
could I have one which also validate this sort ....
I am trying to find an email regexp but none seem to validate the following example:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@xx....xxx.xxxxxx.xx
could I have one which also validate this sort ....
My understanding of regular expressions is rudimentary, at best.
I have this RegExp to to a very simple validation of an email-address, but it turns out that it refuses to accept mail-addresses with hypens in them.
Can anybody please help me adjust it so it will accept addresses like dag-sunde@test-domain.net too?
Here's what got:
function validateEmail(eMail) {
return /^(w+.)*(w+)@(w+.)+([a-zA-Z]{2,4})$/.test(eMail);
}
I am attempting to do a basic email format validation in JavaScript on a very basic form with fields for name, address, email, etc.
Requirements: A period can occur before the @, but not twice in a row -- as in jane.doe@xyz.com but not jane..doe@xyz.com. Email must start with a letter. I'm also allowing underscores and hyphens before the @, but I'm not worrying about whether there's only one of each -- I'm just allowing those. Must end in .com, .net, .org. Nothing else.
[Code]...
I have read extensively on this site and several others and haven't found a solution to the "one and only one period allowed in succession, but not required" problem. I haven't found a successful way to limit periods to only 1 in a row yet still have the rest of the validation work properly. I get the symbols in general, but as a newbie can't seem to make them do this one thing that I want them to do.
I want to check the email address type in a contact form but want to reject it if it's from a certain domain I actually use this regexp : /^[a-zA-Z0-9_.-]+@([a-zA-Z0-9-]+.)+[a-zA-Z0-9]{2,4}$/ (taken from the jquery validationengine) to check if the email address is correctly formated but I'd like to reject it if contains hotmail between the @ and the. I tried many things but couldn't get something that works.
View 2 Replies View RelatedI'm finally diving into regexp by porting a perl script over to js that uses regexp to compress javascript into a bookmarklet capable format.I've successfully worked out 90% of the expressions but am troubled with a few, this one at the moment is odd:I want to remove the first line if it hasjavascript:So I thought str.replace(/^javascripts+:s+/, "") would be ok. I want javascript text, any space, colon, any space and new line. what I'm doing wrong.btw this is the original perl version
$src =~ s{^// ?javascript.+:.+
}{};
I found this in felgall's page. I added script tag
<script type="text/javascript">
var re = /(t)he/g;
var mystring = "Over the moon.";
re.text(mystring);
alert(RegExp.input); // or RegExp.$_
alert(RegExp.leftContext); // or RegExp["$`"]
alert(RegExp.rightContext); // or RegExp["$'"]
alert(RegExp.lastMatch); // or RegExp["$&"]
alert(RegExp.lastParen); // or RegExp["$+"]
alert(re.source);
</script>
I don't see message box. Please tell me what I can do.
Heres my javascript code that will verify email from email input field and check if the checkbox (I agree condition) was checked:
[Code]....
However, this will work fine when calling with a link "javascript:validate('inputForm');" but if I try to prevent users by submitting form with pressing enter I put it in form onSubmit parameter: <form .. onSubmit="javascript:validate('inputForm');"> which will check the forms and submit data (do return) no matter if it matched or no.
Last week after much searching, I found the answer to my problem in
this newsgroup. I can't find the thread from which I got my solution,
but I wanted to report back what worked.
When the site visitor fills out the form and submits it, this calls a
rather ordinary asp script like formmail.asp that sends the emails and
displays a "thank you" web page. At the very end of my "thank you" web
page I placed the following:
<script type="text/javascript">
location.href="FileToDownload.exe"
</script>
This causes the file download to get triggered, and asks the user if
they want to save the file. In limited testing this appears to work
fine in both Firefox and IE.
I'm a mediocre website designer i know html , at JS i'm to noob to actualy make something of my own :) just Edit, i'm still learning and atm i'm working on a web project and I'm struggling to find a way to Filter email addresses to redirect my New Members to their e-mail provider, for example if they would register newmmember@hotmail.com to be forwarded to www.hotmail.com so they would login and activate their account, or if they enter @yahoo.com to be forwarded there . Can you please point out a few things i'm eager to learn how to Forward User to email provider after he creates his account . Or how can i forward email to URL inside my webpage , this could help me with another ideea i have, again this would have to be filtered @yahoo.com , @hotmail.com etc , to be forwarded to a local URL inside the site depending on what Email Provider they enter .
View 5 Replies View RelatedI have a frameset and one of the frames contains a page that is created on the fly, an
actual word document. I want to have a button in one of the other frames that emails this created page as an email attachment using the email client (outlook or whatever). I created a function as follows:
<script language="JavaScript">
function mailIt()
var page = parent.QandA;
document.write 'mailto: sendmail@example.com?subject=The
document&Attachment='
document.write page;
}
</script>
Which is then called from a button, but it doesnt work! QandA is the
name of the frame that contains the document I want to email as the
attachment.
Im using the old nopcard scripts on my site. It does every thing right except it does not send a Email to my to my email adres. I dont know how to correct this because i dont know Javascript. I include the script if anybody know how to alter it so that it will send the info to my email adres as well.
The checkout.pl script :
i hv an input box like this
<td >
<input type="text" name="emailid" id="emailid" onBlur="checkMail(this)" value="emailId" onFocus="this.value=''">
@domain.com</td>
[Code]...
Now problem is as u can see .. i hav to check just "EMAIL ID" not the full "Email address".. i cud not be successful to edit the JS function.
i have some script java script which is working but i want to do it some thing else
[Code]....
This script is working for email validation also if email box is empty it says to fill it i want that for all if some one left any box in form it says fill that. i have tried many ways but failed that's why posting here. and the last function is for contactno INPUT field so one can only put number in the field. HTML CODE
[Code]...
Looking for a good tutorial on how to use jQuery to read email sent tomy site's email address, and how to send email through my site'semail. Basically, how to construct the server email portion of
View 11 Replies View RelatedIs it possible to create a page (with javascipt) that will send an email to the "me" but the user can't see the destination email address? Im wondering if I can do the "party" with Javascript without using some server page like PHP.
View 1 Replies View RelatedI need to create a dynamically pattern match
for validate a number input, first without
decimals and then with 2 or more decimals.
i have this function to check date (not mine)
function (s_date) {
// check format
if (!re_dt.test(s_date))
return false;
// check allowed ranges
if (RegExp.$1 > 31 || RegExp.$2 > 12)
return false;
// check number of day in month
var dt_test = new Date(RegExp.$3, Number(RegExp.$2-1), RegExp.$1);
if (dt_test.getMonth() != Number(RegExp.$2-1))
return false;
return true;}
it will check in this format DD-MM-YYYY
is it possible to modify it to be (MM/DD/YYYY OR DD/MM/YYYY) in one function?
I am weak when it comes to regexp but hoped someone might know in this case.
I am trying to take a url like this :
something.lasso?blah=blah&blah2=blah2&sort=hello&blah3=blah3
And remove the &sort=XXX without hurting the rest of the url. The parameter
to be replaced would be a parameter passed to a function. Here is what I
have so far:
function refresh(item) {
current = document.location.href;
if(current.match(item.name+'='))
//pseudo code here
//current.replace(item.name regexp , '');
return (current + "&" + item.name + "=" + item.value);
This function would be fired like this :
All <input type="radio" name="show" value="all"
onclick="document.location=refresh(this);">
Mine <input type="radio" name="show" value="mine"
onclick="document.location=refresh(this);">
An important question, probably not treated by many otherwise worthwhile
sources, must be on feature detection of the newer RegExp facilities -
for example, greedy/non-greedy.
The answer may be that it is not possible to do so in a safe manner;
that one can do no better than something like
document.write("Testing non-greedy :- ")
X = /<trialRegExp>/.test(string)
document.write("survived.")
That is, nevertheless, a useful answer; if it is right, it prevents the
naive seeking anything better, and if it is wrong someone will soon say
so.
Where a page requires an advanced RegExp facility, it is best to have a
controlled failure at a well-chosen point.
Putting something in the posted FAQ will provide an opportunity for
adding a reference to the Notes; and, without such a reference, their
value is much reduced.
I have a script that checks if the value of the input is valid but I have a problem with it. This is my RegExp code:
if(obj.value.match(/!@#$\%^&*()+/g))
obj.value = "Use only legit characters";
It's supposed to check if the input value has invlaid code but it doesn't seem to work.
Also I'd like to, instead of just writing the error message, to be able to change the input value to a valid one(IE: Peo$p@le@ To People)
I think it can be done with the replace statement like this:
obj.value.replace(/!@#$\%^&*()+/g,"")
So whenever it finds that invalid char it just writes nothing instead of it.
I have found that I can't use a regexp variable twice. For instance, if I have the following code then the first will evaluate true and the second one false, despite the fact that they should both evaluate true:
reg = RegExp('[AF]PO', 'gi');
if (reg.test(document.getElementById('address_line_1').value) && reg.test(document.getElementById('address_line_2').value))
alert('You entered an APO or FPO address!');
To get the code above to work I have to do the following:
reg = RegExp('[AF]PO', 'gi');
reg2 = RegExp('[AF]PO', 'gi');
if (reg.test(document.getElementById('address_line_1').value) && reg2.test(document.getElementById('address_line_2').value))
alert('You entered an APO or FPO address!');
Why is it I have to have two regexp variables created? Is the variable "one use" or am I doing something wrong here?
Can someone please let me know what this matches - i can work out some but not all code...
View 3 Replies View Relatedim tired of working all day...
please how to delete the value with regexp...
i tried this
bla.replace('value="/.+/"', '');
it wont work...
I want to replace a string after checking it is valid by passing the values to a function.
The string is '<img width="300" height="300">'
Code:
var text = '<img width=300 height=300>'
text = text.replace(/<img width=(.*?) height=(.*?)>/gi, check_img($1, $2));
The $1 and $2 values are not being passed to the function.
This same method works in PHP by the e Modifier but not in JS.
Given a string like:
<input type="button" name="b1" value="Button">
I want to locate the element's name (b1) and replace it with this very name
+ some spice.
And of course it can be any kind of loose HTML syntacs:
name="b1"
NAME="b1"
name='b1'
NAME=b1
....
So it's something like (totally wrong expression, I know):
/name=(s+|'|")(name)/$1+my_spice/i
But I did not work with regexp for a longest time, and I'm just too lazy (sorry to admit) to read manuals over again just for one case.
Consider the following RegExp:
/[1]/
ECMA-262 says:
<quote (with slight modification of non-ASCII character)>
15.10.2.11 DecimalEscape
The production DecimalEscape :: DecimalIntegerLiteral [lookahead != DecimalDigit] evaluates as follows.
1. Let i be the MV of DecimalIntegerLiteral.
2. If i is zero, return the EscapeValue consisting of a <NUL> character (Unicode value 0000).
3. Return the EscapeValue consisting of the integer i.
...