Author |
Message |
metsfan922
Junior WebHelper
Joined: 09 May 2002
Posts: 15
|
Posted:
Fri May 10, 2002 3:48 pm (21 years, 11 months ago) |
|
i declare two text boxes text1 and text2 and use them for form validation in JS, in a .php file. however, on the next page when i try to use text1 and text2 in php, it seems taht since i used them in javascript, i cannot use them in the next page which is in php. why cant i use the same variables for JS and PHP? if i can, why am i getting errors? |
|
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Fri May 10, 2002 3:58 pm (21 years, 11 months ago) |
|
Javascript is CLIENT side, and PHP is SERVER side. The two do not interact with each other unless special measures are taken. |
________________________________
|
|
|
|
metsfan922
Junior WebHelper
Joined: 09 May 2002
Posts: 15
|
Posted:
Fri May 10, 2002 8:33 pm (21 years, 11 months ago) |
|
unless u know a way to do form validation with php, how do u do that? |
|
|
|
|
Darren
Team Member
Joined: 05 Feb 2002
Posts: 549
Location: London
|
Posted:
Fri May 10, 2002 9:32 pm (21 years, 11 months ago) |
|
Depends what you want to validate.
If its just that the field has been filled in you can use, something like:
Code: | if(empty($field)) {
//field is empty, give error message
} else {
//process form e.g. email it or add it to db
}
|
You can also use regular expresions to check the field contains certain data e.g that a phone number contains numbers. |
|
|
|
|
metsfan922
Junior WebHelper
Joined: 09 May 2002
Posts: 15
|
Posted:
Sat May 18, 2002 4:31 am (21 years, 11 months ago) |
|
we are not all php mongers here. i am a mere amature. that long chain of slashes and letters and numbers have no meaning to me. if ur gonna post something on a help board, u have to newbify it |
|
|
|
|
php4ever
Junior WebHelper
Joined: 10 Oct 2002
Posts: 49
|
Posted:
Sat May 18, 2002 5:01 pm (21 years, 11 months ago) |
|
is an example of a regular expression. I realize now that this chain of characters may look a bit overwhelming to newbies but once you understand how to compose one, you will find that it can be helpful whether you choose to code in PHP, Perl or JavaScript. In this particular case, the regular expression does as I describe in the comment above it. If you need to learn how to create or interpret a regular expression, I suggest that you may wish to review Chapter 8, "Regular Expressions" IN: PHP for the World Wide Web by Larry Ullman (Visual Quickstart Guide), Peachpit Press, 2001. |
|
|
|
|
Peter
Team Member
Joined: 09 Jan 2002
Posts: 147
Location: UK
|
Posted:
Sat May 18, 2002 8:35 pm (21 years, 11 months ago) |
|
metsfan922 wrote: | we are not all php mongers here. i am a mere amature. that long chain of slashes and letters and numbers have no meaning to me. if ur gonna post something on a help board, u have to newbify it |
If you want to learn you have to make some effort. We are here to help you, not to teach you. Buy yourself a book and spend time teaching yourself. Then ask questions when you get stuck.
That chain of slashes and letters is a regular expression. If you want to really understand them then buy the book "Mastering Regular Expressions" which tells you absolutely everything you need to know. |
________________________________ Maple Design - quality web design and custom programming |
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Sun May 19, 2002 7:59 am (21 years, 11 months ago) |
|
|
|
|
|
Page generation time: 0.141614 seconds :: 21 queries executed :: All Times are GMT
Powered by
phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme