Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #19230
| Message-ID | <7867864.kBbL0iy7tU@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2013-04-11 20:40 +0200 |
| Subject | Re: Restrict a domain on Email Validation |
| Newsgroups | comp.lang.javascript |
| References | <9e42c475-f0f4-4822-98d4-0291745f3447@googlegroups.com> |
GarryJones wrote:
^^^^^^^^^^
There should be a space character between first and last name so as not to
appear as a pseudonym and being subject to the respective filters.
> I am currently using this code to validate emailadresses on user forms.
>
> function checkform ( form ){
Code conventions:
function checkForm (form) {
or
function checkForm (form)
{
I prefer the latter in order to tell function expressions and function
declarations apart.
> if
> (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
Wrong, see RFC 5322 (and predecessors newer than RFC 822).
> .test(form.bokept.value))){
.test(form.elements["bokept"].value))
{
> var answer = confirm("Invalid or incorrect email address
^
Unterminated string literal ----------------------------------'
> \n Click Cancel if you want to try again
> \n Click OK if you don't have an email address
> \n Click OK if our system does not allow your email adress
> \n If you click OK we will insert a dummy email address for our
> purposes")
> if (answer){form.bokpap.checked = true;
> form.bokept.value = 'missemail@mydomain.se';
You really do not want to include e-mail addresses (verbatim) in client-side
code. Also, do not use potentially existing domains for dummy values or
examples. Use the “invalid” top-level and “example” top-level and second-
level domains. See RFC 2606.
> return false ;
Convention is: No space before “;”.
> } else {
> form.bokept.focus();
> form.bokept.value = '';
Proprietary referencing; avoid, see above.
> return false ;
See above.
> }
> }
> return true ;
See above.
> }
>
> This has served me well since 2005.
Doubtful, as it does not compile due to syntax errors.
> Now I need to make a change.
>
> I can no longer allow users to use email addresses from a certain domain.
>
> How can I change the script to block all email addresses from @forbidden.*
…
&& !/@forbidden\.[^.]+$/.test(…)
As you can see here, it is not necessary to put the test() call in
parentheses.
> (Where * can be org, com. co.uk, se ...... etc)
>
> ?
>
> Any help greatly appreciated.
Adaptation of the client-side code certainly helps to reduce unnecessary
roundtrips. But you must also check potential addresses server-side to
fulfill the requirement. (You should have done so before.)
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Restrict a domain on Email Validation GarryJones <morack@algonet.se> - 2013-04-11 10:33 -0700
Re: Restrict a domain on Email Validation Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-11 20:40 +0200
Re: Restrict a domain on Email Validation Stefan Weiss <krewecherl@gmail.com> - 2013-04-11 20:53 +0200
Re: Restrict a domain on Email Validation Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-11 21:09 +0200
Re: Restrict a domain on Email Validation Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-11 21:35 +0200
Re: Restrict a domain on Email Validation Stefan Weiss <krewecherl@gmail.com> - 2013-04-11 21:49 +0200
Re: Restrict a domain on Email Validation Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-11 22:04 +0200
Re: Restrict a domain on Email Validation Stefan Weiss <krewecherl@gmail.com> - 2013-04-11 23:25 +0200
Re: Restrict a domain on Email Validation Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-11 23:31 +0200
Re: Restrict a domain on Email Validation Stefan Weiss <krewecherl@gmail.com> - 2013-04-12 00:23 +0200
Re: Restrict a domain on Email Validation Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-12 00:42 +0200
Re: Restrict a domain on Email Validation Stefan Weiss <krewecherl@gmail.com> - 2013-04-13 11:36 +0200
Re: Restrict a domain on Email Validation Scott Sauyet <scott.sauyet@gmail.com> - 2013-04-20 13:30 -0700
Re: Restrict a domain on Email Validation Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-12 00:51 +0200
Re: Restrict a domain on Email Validation Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-04-12 19:36 +0100
Re: Restrict a domain on Email Validation "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-04-13 10:40 +0200
csiph-web