Preventing "JavaScript disabled users" to send unvalidated forms.
This simple code I wrote, and just wanted to share.
Actually you can (and you should anyway) always check the post variables in the second page, but this code prevents users clicking "submit" buttons if JavaScript disabled:
Put this on top of your page, and call the function from BODY tag. You also have to disable all your submit buttons:
This simple code I wrote, and just wanted to share.
Actually you can (and you should anyway) always check the post variables in the second page, but this code prevents users clicking "submit" buttons if JavaScript disabled:
PHP Code:
<SCRIPT TYPE="TEXT/JAVASCRIPT" LANGUAGE="JAVASCRIPT">
function enable(){
var formQ = document.forms.length;
for(var xx=0; xx<formQ; xx++) {
var formElementQ = document.forms[xx].elements.length;
for(var yy=0; yy<formElementQ; yy++){
if(document.forms[xx].elements[yy].type.toLowerCase()=="submit")
{
document.forms[xx].elements[yy].disabled = false;
}
}
}
}
</SCRIPT>
PHP Code:
<BODY onLoad="enable()">
<INPUT TYPE="Submit" NAME="Send" DISABLED>
Comment