Question
server-client form validation
Hello to All!!
I'm thinking about site-validation, I'm going to use both: server & client. But I don't want to give to server extra work.
For example:
I want to validate a simple text input in a form (text must have from 3 to 15 symbols)
<form name="myform" method="post" action="action.cfm" onsubmit="return validation();">
<input type="text" name="name">
</form>
On the "form-page" I write:
<script language="javascript" type="text/javascript">
function validation(){
if ((document.myform.name.value.length < 3)||(document.forma.name.value.length > 15)){
alert ("ERROR");
return false;
}
return true;
}
</script>
But on the action.cfm page I also have:
<cfscript>
if (structKeyExists(form,"name") and len(trim(form.name))) {
variables.name = Len(form.name);
if (name LT 3 or name GT 15) {
writeoutput("ERROR") ;
}
}
</cfscript>
So my <cfscript> will always work, when form will submit, even when form will submit with CORRECT DATA after "script-check".
How I can identify that client turn off "enable javascript"??? Can I do it with CGI, how???
Thanks for your comments!!!
I'm thinking about site-validation, I'm going to use both: server & client. But I don't want to give to server extra work.
For example:
I want to validate a simple text input in a form (text must have from 3 to 15 symbols)
<form name="myform" method="post" action="action.cfm" onsubmit="return validation();">
<input type="text" name="name">
</form>
On the "form-page" I write:
<script language="javascript" type="text/javascript">
function validation(){
if ((document.myform.name.value.length < 3)||(document.forma.name.value.length > 15)){
alert ("ERROR");
return false;
}
return true;
}
</script>
But on the action.cfm page I also have:
<cfscript>
if (structKeyExists(form,"name") and len(trim(form.name))) {
variables.name = Len(form.name);
if (name LT 3 or name GT 15) {
writeoutput("ERROR") ;
}
}
</cfscript>
So my <cfscript> will always work, when form will submit, even when form will submit with CORRECT DATA after "script-check".
How I can identify that client turn off "enable javascript"??? Can I do it with CGI, how???
Thanks for your comments!!!
