How to code minimum entry

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adsegzy
Forum Contributor
Posts: 184
Joined: Tue Jul 28, 2009 9:26 am

How to code minimum entry

Post by adsegzy »

My fellow success-oriented people,

i need to code my password field to contain the minimum character of 6 characters and reject any entry lesser than 6 characters. How do i do it?

Regards
adsegzy
nshiell
Forum Newbie
Posts: 12
Joined: Mon Oct 19, 2009 12:20 pm

Re: How to code minimum entry

Post by nshiell »

Flattery'll get u nowhere lol
In php it would be something like

Code: Select all

 
if (strlen($_GET['password']) < 6)
{
// Do something to let user know that the form has been refused
}
 
If you have time you could also do a JavaSCript as well AFTER YOU HAVE GET THE SERVER SIDE WORKING!

Code: Select all

 
<script type="text/javascript>
function validateForm()
{
if (getElementById('password').value.length < 6)
{
alert('BAD');
return false;
}
}
</script>
<form action="#" method="get" onsubmit="validateForm()">
<input type="password" name="password" id="password">
</form>
 
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: How to code minimum entry

Post by JNettles »

Probably shouldn't double-post your questions either.........
Post Reply