-
easy question for more experienced - RE: forms
Having some trouble with this.
Should be a cinch for a more experienced scripter.
I need to set up a form that will have one of the fields checked.
It needs to validate the number of characters entered in ordered to proceed.
e.g. must enter 18 characters.
Haven't been able to figure out a way and prefer not to use js.
Any help appreciated. Thanks in advance!
-
Hello fla999,
If you are using PHP you can use a function that checks the string length:
if (strlen($your_variable)<18) {
//DO THIS IF TRUE
} esle {
//DO THIS IF FALSE
}
You can go to:www.php.net to learn more about PHP.
Hope I helped a bit,
Loo
-
There is a type-o
Here is the correct code with the correction in bold:
if (strlen($your_variable)<18) {
//DO THIS IF TRUE
} else {
//DO THIS IF FALSE
}
-
Hey Loo
Appreciate the help.
I'm not up to speed on this, but can you explain
//DO THIS IF TRUE
} else {
//DO THIS IF FALSE
}
It says 'do this if true' > but what is it to do?
followed by
} else {
-------
excuse my ignorance.
When I look at this, I see it trying verify the string length.
I don't get what it is supposed to do whether it is true or false.
-
Sup fla999,
OK here it goes :
if (strlen($your_variable)<18) {
print"You have NOT entered 18 characters";
} else {
print"You HAVE entered 18 or more characters";
}
Meaning that if what you have typed is less than 18, print to browser "You have NOT entered 18 characters", but if its not less than 18(or else ) print "You HAVE entered 18 or more characters".
PHP is an open source language meaning its FREE .
You should look up a tutorial about PHP, its pretty easy to understand.
Trust me, you'll see.
Good luck,
Loo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|