function validate(form){
//var controls = form.elements;
alert("start");
if (form.comment[body].length > 256) {
alert('Please limit your message to 256 characters. There
are currently ' + form.comment[body].length + '.');
return false;
}
else {
return true;
}
}
</script>
cant help with the referencing problem, but you should never do a
(solely)client-side validation of user data anyway.
It's always best to do this at the server since even though you
validated it with javascript the user can send you a manipulated
request with whatever data he chose. So client-side validation would
only be a user-friendly feature, cause he gets instant feedback.
Rails offers lots of options for (server-side) data validation
(validates_presence_of, validates_length_of,
validates_numericality_of........)
cant help with the referencing problem, but you should never do a
(solely)client-side validation of user data anyway.
It's always best to do this at the server since even though you
validated it with javascript the user can send you a manipulated
request with whatever data he chose. So client-side validation would
only be a user-friendly feature, cause he gets instant feedback.
Rails offers lots of options for (server-side) data validation
(validates_presence_of, validates_length_of,
validates_numericality_of........)
hope that helps! good luck, simon
On Jun 24, 5:42�am, Scott Kulik <rails-mailing-l...@andreas-s.net>
I agree u should use validates_length_of rather than a JS for
restricting the user to a certain limit
thanks for the help! i used validates_length_of and it's working
perfectly. Maybe one day i'll go back to the javascript just to add
another user friendly reminder so they are aware before they submit the
form.