Hello. JavaScript et al.
I'm interested in opinions for validating data within a form. Is the following correct:
1. An email will always include an at '@' sign. Will it also (always) include a period (.)? And no spaces.
2. It's (almost) impossible to validate an URL. It can include any characters, including spaces (%20)?
Andy.
Approach to form validation
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Approach to form validation
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Approach to form validation
Search Google for regular expressions to validate e-mail addresses and URLs. There are some very clever solutions out there.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Approach to form validation
I'm happy working with regular expressions, but I just want to confirm - does every e-mail address contain @, a dot and no spaces?
I've seen many examples that try to validate URLs, and a lot of advice that it is not sensible to try this. Perhaps every url contains at least one of these
characters: \ / or . (period)? Andy.
I've seen many examples that try to validate URLs, and a lot of advice that it is not sensible to try this. Perhaps every url contains at least one of these
characters: \ / or . (period)? Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Panoramic Lounger
- Posts: 8188
- Joined: 25 Jan 2010, 09:09
- Location: retirement
Re: Approach to form validation
If I use the 'Block sites' feature on my Netgear router and use . (period) as the keyword then it warns me that this will block all sites. That suggests to me that all URLs do contain a . (period).
Ken
Ken
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Approach to form validation
Thank you. I just remembered that some browsers or search engines will even accept a single word (bbc, ebey, etc.) and 'www.' seems to be assumed most often these days.
Perhaps the only way to sensibly validate is to use a server-side script and send a http (or ping - is that the term?) request.
I'm still curious as to whether every email contains a dot . Andy.
Perhaps the only way to sensibly validate is to use a server-side script and send a http (or ping - is that the term?) request.
I'm still curious as to whether every email contains a dot . Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- GoldLounger
- Posts: 2599
- Joined: 24 Jan 2010, 15:26
- Location: Olympia, WA
Re: Approach to form validation
These browser are smart enough to add the ".com" or even a FEW of the other well known sites, but not all of themagibsonsw wrote:Thank you. I just remembered that some browsers or search engines will even accept a single word (bbc, ebey, etc.) and 'www.' seems to be assumed most often these days.
I'm still curious as to whether every email contains a dot . Andy.
Yes, ALL domains have a "Dot" something, this includes websites and email addresses.
Have a good read at http://en.wikipedia.org/wiki/Domain_Name_System" onclick="window.open(this.href);return false;
I guess that you could use anything you wanted as long as you could convince "ICANN " that you really needed to.
I am so far behind, I think I am First
Genealogy....confusing the dead and annoying the living
Genealogy....confusing the dead and annoying the living
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Approach to form validation
As Dave mentions, every (complete) e-mail address contains at least one dot after the @. And spaces aren't allowed.
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Approach to form validation
In case you're still interested, here are some links:
How to Find or Validate an Email Address
How To: Use Regular Expressions to Constrain Input in ASP.NET
How to Find or Validate an Email Address
How To: Use Regular Expressions to Constrain Input in ASP.NET
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Approach to form validation
Thank you.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.