Just remember to check your data on the server every time, regardless of if you have JS do it or not.
<script type="text/javascript">
function validate_this_form () {
var input = document.getElementById('inputText');
if (input.value != 'foo') {
alert('You must enter the value "foo" to proceed');
return false;
}
return true;
}
</script>
<form action="page.php">
<input id="textInput" type="text"/>
<input type="submit" name="bar" onclick="return validate_this_form();"/>
</form>
Have just seen this.. you're point is spot on. Worry about getting an application up and running, then refactor if necessary.Worrying about a single database query that selects a single integer in an event so rare as user registration is premature optimisation.
Also, as if `array_map` is actually faster—it's not like it doesn't compile into the same instructions as manually looping through the array.
Lots of these criticisms are just irrelevant based on the inevitable use of the code, and at the end of the day if your site ever does get popular you're probably always going to see more benefit by moving to memcached than you would by doing all of these tiny optimisations.
Don't need to include all of it, just the basic handy stuff - eg required fields, minimum length etc - v usefuli guess it depends how fields you need to check. i'd probably rather let someone submit an incomplete form rather than duplicate all my php validation in javascript. for the most part, normal people usually fill forms in correctly. i think i can live with a few wasted POST requests to my server. and you can still display nice prompts to users and keep the fields filled with their values using php.![]()
Have just seen this.. you're point is spot on. Worry about getting an application up and running, then refactor if necessary.