Hey, i have 4 textfields and i need to check that at least two of them are full.
Would it b better to check it client-side using JS or server-side using PHP?
Can anyone please help??
Thanks
Printable View
Hey, i have 4 textfields and i need to check that at least two of them are full.
Would it b better to check it client-side using JS or server-side using PHP?
Can anyone please help??
Thanks
Server Side using PHP, since people can simply turn off Javascript. For convience you can check client side as well, saves the user submitting the form only to find its not done right, and its reduces the amount of work the server has to do, since almost always its going to be full. :)
OK, so... say i do it with Javascript, how do i check that at least 2 of the 4 textfields are not empty.
And also, how would i do it with PHP if anyone know?
Thanks, if you know how to do it with either of the languages i would be most grateful
BIOSTALL
Are not empty? Not Empty in Javascript is easy, but if you want greater-than-certain-length then it gets abit harder I think, I can't remember all the javascript functions.
No gurantees that the code is right, I'm to lazy to test.
To check atleast 4 aren't empty, you could use a variable to count how many times a textbox is found to be empty (or not empty whichever way you want to look at it :p), and after you've done checking each you can check if the variable is greater than 2 or not.Code://Javascript
if(document.formname.textboxname.value != '') {
alert('not empty');
}
Code://PHP
if(trim($_GET["mytextboxname"]) != "") {
print "No Nullness today :)";
}