473,769 Members | 5,205 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript email validation

4 New Member
Hello, im posting this question because i have zero knowledge on javascrip. I have a script which curently allows users to imput an email address and if the email is not valid it wont allow the submission. Everything works fine except that now there are clients who have a period in their email address and it is rejected. eg. tom.jones@email .com.. im sure its a simple addition to the script not even sure where it might go but here is what i copied and where im assuming it might need to be changed..

Expand|Select|Wrap|Line Numbers
  1. # Do our error checking
  2.   my $gintErrorCount = 0;
  3.   my $gstrMessage = "";
  4.  
  5.   # Email Address
  6.   unless ($gstrHash{email} =~ m/^(\w+)\@(\w+)\.(\w{2,4})$/)  {$gintErrorCount ++; $gstrMessage .= "Your email address is not properly formatted.<BR>";}
  7.  
  8.   # Fix phone variable - client
  9.   $gstrHash{cphone} =~ s/\D//g;
  10.   unless ($gstrHash{cphone} =~ m/^\d{10}$/) {$gintErrorCount ++; $gstrMessage .= "Your contact phone number must be a ten digit number.<BR>";}
  11.   $gstrHash{cphone} =~ s/^([\d]{3}?)([\d]{3}?)([\d]{4}?)$/\($1\)$2-$3/i;   
  12.  
  13.   # Email Address
  14.   unless ($gstrHash{cemail} =~ m/^(\w+)\@(\w+)\.(\w{2,4})$/)  {$gintErrorCount ++; $gstrMessage .= "Your contact email address is not properly formatted.<BR>";}  
  15.  
i appreciate any help
thanks
EMI
Sep 4 '08 #1
6 1973
RamananKalirajan
608 Contributor
I am sorry i am not able to get your requirement clearly. what u are trying to add in that script. you specified that the client has a period in email id. What is that you wnat to mean. I was not able to get ur point at that line. Are u checking for duplication or checking for any time constraint. please mention it clearly. I will try to help u out

Regards
Ramanan Kalirajan
Sep 5 '08 #2
acoder
16,027 Recognized Expert Moderator MVP
That's not JavaScript code. Are you sure this is on the client-side?

Whatever the case is, you just need to make a change to the reg. exp. to allow a . within the email.
Sep 5 '08 #3
wgale025
23 New Member
That is php code!!!Not javascript code!
Sep 5 '08 #4
acoder
16,027 Recognized Expert Moderator MVP
I think it's Perl actually.

@EMI, do you want this on the client-side?
Sep 5 '08 #5
emirapoport
4 New Member
Sorry Guys,
yes you are right...i was wrong this is actually perl.
I guess i should post in the proper area..like i mentioned im clueless about this stuff...
Yes this is actually a form that requires whoever goes to the site to imput an email address. Everything works great but since poeple now have a period in the emails..whateve r restrictions have been coded with the email requirements dont allow for periods in the first part of the email (eg, tom.jones@email .com).
I just want to allow periods to be submitted.
Thanks fo rthe replies
EMi
Sep 8 '08 #6
acoder
16,027 Recognized Expert Moderator MVP
I was about to move this thread when I realised that you've already posted in the Perl forum. If you ever need client-side email validation, you can come back to this thread.
Sep 8 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2692
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one function to verify the name fields, age, email and gender. My question is: if I create a function for each field like the code below, what would be the best way to organize the functions and call them? Would I need one main function and place...
111
14430
by: Retlak | last post by:
The recommended (on dozens of websites) and effective (works in Netscape, MSIE, Mozilla, probably others) way to detect if a browser has Javascript turned off is to put this in the <head>: <noscript> <meta http-equiv="refresh" content="1;url=http://yourURL/nojscript.html"> </noscript> This redirects to a doc which typically says "You need to enable
13
1700
by: rcb845 | last post by:
Hi everybody Javascript specialist, I am relatively new in Javascript world. I have a problem to solve and I hope one of you can help me. I am building a validation system, i.e. I want to validate data entered using A normal HTML FORM. Data will be checked using Javascript scripts to Have an immediate status, and to prevent user to keep on in case of error. But some data must be checked against MySql database accessed through
2
13274
by: techfuzz | last post by:
I scoured this group and others looking for the best way to disable a button after the first click to prevent multiple submissions, but never did find anything that worked like they said it would. I went ahead and wrote my own bit of code so I'm sharing it here for everyone. Even though it doesn't really disable the button by greying it out, it prevents the multiple submissions which it what I was attempting to prevent all along. ...
5
2136
by: Allan M. | last post by:
I have a series of select boxes that must be populated client side, because they interact with each other. The design specification calls for these boxes to be updated without having to make a roundtrip to the server. The codebehind seems to be unaware of select box members populated via javascript. So, I'm having to create my own state management solution, (i.e. rewriting the VIEWSTATE mechanism) to persist the state of these select...
3
1754
by: Ronan Dodworth | last post by:
Hi there I'm having a little bit of a problem with my customvalidator control. The problem is the javascript runs fine on my local webserver IIS but not when I post it to the web hosting server. As it is client side scripting I'm suprised that this is the case as I'm using the same browser IE6 and the same machine to access both. I've included the code below. Can anyone help . I've tried lowering all the security settings for intranet...
5
2418
by: M | last post by:
Hi, it's possible to append a custom action to a client-side verification of a validation control ? I have a validator summary control that shows (automatically) a message box if the validation of the validators in the page fails; after the user close this message box I have to perform a client-side function (hiding some text) ... it's possible? Thanks!
5
2647
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze in 1.1 since I could edit the .js file. Now in 2.0 I can no longer do this. Also, my code would have to be called after all client-side validation was done and was successful. Any ideas? TIA!
8
3674
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
27
4753
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it appears that the data goes straight to the processing page, rather than the javascript seeing if data is missing and popping up an alert. I thought it may be because much of the form is populated with data from the db (lists, etc.), but when I leave...
0
10050
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.