The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Validating forms - examples?
Discuss Validating forms - examples? in the PHP Development forum on Dev Shed. Validating forms - examples? PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 9th, 2000, 09:58 AM
|
|
Junior Member
|
|
Join Date: Apr 2000
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Hi,
I want to validate forms. I want to check the following.
* Has the user given a valid e-mail address?
* remove all leading and trailing spacebar-hits
* Check if only text has been inputted in a textfield
* if a valid date is given
* Check if only numbers have been inputted in an input field
* all other checks I may have left out.
Thanx in advance,
Dj Mouse
|

May 10th, 2000, 06:12 AM
|
 |
.Net Developer
|
|
Join Date: Feb 2000
Location: London
Posts: 987
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
|
|
|

May 10th, 2000, 06:52 AM
|
|
Junior Member
|
|
Join Date: Apr 2000
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
SR,
Thank you man! I'm already checking out those lessons on webmonkey. If you have some more of these links, please send me/e-mail them to me.
Thanx!
Dj Mouse
|

May 10th, 2000, 11:41 AM
|
|
Junior Member
|
|
Join Date: Apr 2000
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
SR,
I do have another question.
I looked at the code at Webmoney and now I'm trying to build my own validatechecker with the ereg() function. Here's what I'm trying to do:
I want the users to enter a valid "postcode".
A postcode contains exactly 4 leasing digits and 2 trailing letters, i.e.
1023DE or 1023 DE are valid postcodes
,but
12345 SED is not valid even as HDSK 12 is not valid.
I tried the following code, but it won't work.
function ValidPostcode($formname) {
if (!ereg("^[0-9]{4,4}[ t]{0,9}[[:alpha:]]{2,2}$",$formname) {
echo "No valid postcode!";
return false;
} else {
return true;
}
}
Do you have any suggestions?
Thanx,
Dj Mouse
|

May 11th, 2000, 07:17 AM
|
|
Contributing User
|
|
Join Date: Nov 1999
Location: UK
Posts: 50
Time spent in forums: 2 h 21 m 33 sec
Reputation Power: 14
|
|
|
Hi,
Can I make a suggestion. Everything that you have requested in your original message can be done in JavaScript. Save yourself a lot of hassle by doing it client side.
Falcon
|

May 11th, 2000, 07:40 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
Javascript has its plus sides but not for form field validation. I apologize if this offends someone. Using javascript to validate form fields is a newbie approach and a bad idea as a web developer.
|

May 11th, 2000, 08:39 AM
|
|
Contributing User
|
|
Join Date: Apr 1999
Posts: 114
Time spent in forums: 42 m 44 sec
Reputation Power: 15
|
|
|
More specifically, client-side data validation is very insecure, since it is very simple for BAD PEOPLE to by-pass your validation just by turning off JavaScript. Then they can enter values into your form that can trick your server side code and/or database software into doing whatever evil things they want.
Always do your data validation server-side.
Now, back to the question at hand:
djmouse, is that a space that's allowed between the digits and the letters, or is it any whitespace character (tab, space, etc.)?
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|