PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 5th, 2002, 06:32 PM
alsaffar alsaffar is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 58 alsaffar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Field Validation

Hi there,

I want to make some validation for the email field in my form,

I want to make sure that the "@" character is exists and the "." is exists also and the email shouldn't start with a space,

name@domain.com // start with a space
namedomain.com // doesn't have a "@"
name@domaincom // doesn't have a "."

So, I want to avoid people keep on submitting invalid addresses.

How can I achieve this?

Reply With Quote
  #2  
Old September 5th, 2002, 06:42 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: Field Validation


Reply With Quote
  #3  
Old September 5th, 2002, 07:12 PM
guyer guyer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Bloomington, IN USA
Posts: 47 guyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to guyer
RE: Field Validation

Here's a client-side version:
Code:
<script>
function checkemail(e){
	var email=String(e.value);
	if (email){
		var reg=/^[w-]+(.[w-]+)*@[a-z0-9-]+(.a-z0-9-]+)*$/i
		if (!reg.test(email)){
			alert("The email address you have entered is invalid.");
			if (String(navigator.appName)!='Netscape'){
				e.focus();
			}
		} else {
			alert("EMAIL OK");
		}
	}
}
</script>

Reply With Quote
  #4  
Old September 5th, 2002, 07:29 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: Field Validation

The problem with client side scripting is that the client can choose to ignore it...

Reply With Quote
  #5  
Old September 5th, 2002, 07:30 PM
guyer guyer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Bloomington, IN USA
Posts: 47 guyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to guyer
RE: Field Validation

That's why I do it on both ends...

Reply With Quote
  #6  
Old September 5th, 2002, 07:37 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: RE: Field Validation

Quote:
That's why I do it on both ends...


Why bother doing it client side if you do it server side? Surely that just increases filesize? Unless you use it for a JS alert() ???

Reply With Quote
  #7  
Old September 5th, 2002, 08:45 PM
guyer guyer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Bloomington, IN USA
Posts: 47 guyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to guyer
RE: Field Validation

Yeah, it's just for the user's benefit...

Reply With Quote
  #8  
Old September 5th, 2002, 09:44 PM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Field Validation

it is always A Good Thing [tm] to check user input on both client and server side.

let me explain:

when u write some js code to check 10-15 input fields, it can add only about 1-2k on the html page, but when a user submits a page with error fields, u have to send him a hole page back, which is usualy over 50k of html (with adds and stuff)

so, it is both for user's benefith, and for less traffic on your site...

Reply With Quote
  #9  
Old September 6th, 2002, 12:03 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: Field Validation

Good point. I hadn't thought of that.... d'oh!

Reply With Quote
  #10  
Old September 7th, 2002, 02:43 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Field Validation

don't worry. it will all come with time and expiriense.

also, wondering on this kind of forums helps.

well, just a year or two ago, i didn't know smth like this, and now i do.

and if i can learn, i think everybody can ;)))

Reply With Quote
  #11  
Old September 7th, 2002, 09:32 AM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: Field Validation

That's the good thing - I would class myself as a good coder (advanced knowledge of PHP, HTML, CSS; resonable knowledge of Perl, JavaScript, MySQL) yet I come to these forums not only to help others but to learn. Since I have taught myself and not used a book, I have a particular style meaning that when I come across a problem, I would use a set method to solve it.

For example, up until about 3 weeks ago, I was trying to use functions to add data to the end of an array, not knowing that you could just use: $array[] = $data;

It's the simple things that are so beneficial to your coding.

Reply With Quote
  #12  
Old September 9th, 2002, 07:24 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: Field Validation

to make it a "super" check, how about adding the ability to open a temporary connection to the hostname provided to see if it actually exists.

Reply With Quote
  #13  
Old September 9th, 2002, 07:37 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: Field Validation

oh. well that makes sense

Reply With Quote
  #14  
Old October 15th, 2002, 11:58 PM
Meche Meche is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: lawrence ,ma 01841
Posts: 1 Meche User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Field Validation

how can ivalidate email using array.

Reply With Quote
  #15  
Old November 5th, 2002, 10:33 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Field Validation

I have a FORM built and I want to add a simple validation code for the email address. So far nothing works with my current FORM. Any ideas ??? (current FORM located here: http://www.partsadventure.com/request2.htm )

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Field Validation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |