Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
hinksta
Worker
Worker



Joined: Dec 23, 2005
Posts: 226
Location: UK

PostPosted: Sat Dec 23, 2006 8:59 am Reply with quote

Is there a way to set a minimum length for an input string or to disable the submit button if no text is entered?

I've found max-length but read that min-length doesn't work in php
 
View user's profile Send private message Visit poster's website
djmaze
Subject Matter Expert



Joined: May 15, 2004
Posts: 727
Location: http://tinyurl.com/5z8dmv

PostPosted: Sat Dec 23, 2006 9:33 am Reply with quote

javascript?

_________________
$ mount /dev/spoon /eat/fun auto,overclock 0 1
ERROR: there is no spoon [ Only registered users can see links on this board! Get registered or login! ] 
View user's profile Send private message Visit poster's website
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sun Dec 24, 2006 9:28 am Reply with quote

Quote:

I've found max-length but read that min-length doesn't work in php


This has nothing to do with PHP. You have to do it client-side (as djmaze is eluding to). The way I would probably approach it is to have the submit button enabled set to "false" to start and then upon the onkeypress event for the text field (the input field), check the length of the text in the input field and if it is >0, set the button enabled to "true".

This should give you a head start. Get a good book on Javascript. My favorite is the JavaScript Bible. It is an excellent reference manual (although I am not where I have my book in front of me at the moment).

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
hinksta







PostPosted: Sun Dec 24, 2006 1:37 pm Reply with quote

Yep, this should be moved to javascript

Found the answer
Code:
<s cript type="text/javas cript"><!--

function checkifempty(){
if (document.formname.inputtextname.value=='')
document.formname.buttonname.disabled=true
else
document.formname.buttonname.disabled=false
}
if (document.all || document.getElementById)
setInterval("checkifempty()",100)
//--></s cript>
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©