how can you set a minimum ammount of words for a textbox in indexu?
say 250 bare min for the description field?
![]()
how can you set a minimum ammount of words for a textbox in indexu?
say 250 bare min for the description field?
![]()
<script>
function CheckLength()
{
var msg_area = document.getElementById("Message");
msg_area.innerHTML = "";
if (document.getElementById("comments").value.leng th < 20) {
msg_area.innerHTML = "YOU DID NOT ENTER ENOUGH INFORMATION";
}
else document.getElementById("testform").submit();
}
</script>
Modify to your requirements
these scripts only work if input type="button" not input type="submit".
indexu simply refuses to submit it the input type is set to button.
from what i can gather if the script was working with input type="submit" the user would recive the minimum ammount of character warning acordingly BUT the form would still submit anyway.
I have tried two scripts now but they require input type="button" to be enabled.
The next problem when i get this working will be knowing how to apply this to more than one <textarea>
good things come to those who struggle![]()
FSGDAG | IndexU Hosting | Owner
Website | NiceCoder Script Hosting and More! | Web4URL is For Sale!
Follow Us On Twitter | FaceBook Profile | YouTube Videos
are you looking for words or characters....???
if you are looking for characters, you can use javascript (getElementById) to test the length of field and change your onsubmit to return a true / false value. something like onsubmit="javascript:return ValidateMinFields(this)". Test as many fields as you like. If one fails the test, popup an alert message and the form is not submitted.
if you are testing for a minimum number of words, you will need to use the javascript split function instead of the length function.
then in the add.php/modify.php test the fields again using the PHP explode function to test for words or the strlen function to test for characters. (NEVER RELY SOLELY ON JAVASCRIPT TO VALIDATE A FORM). If they don't pass the test there, send the user back to the form with the appropriate message.
.
esm
"The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."
.