Form Validation Exposes Variable Name insead of Label Name on the Altert Box - MM_validateForm()
As you see in the snapshot, variable names are shown e.g. "email_address", "email_message" and "email_subject". Instead i want to print "Email", "Message" and "Sub开发者_如何学Cject".
MM_validateForm() Javascript is used for validation.
Two ways to try this.
- Rename your input names, e.g. email_address => Email. This also means you need to rewrite some of your PHP, e.g. $_REQUEST['email_address'] => $_REQUEST['Email'];
A second way without doing a ton of rewriting you could do something like this add this function into your script tags:
function returnUserFriendlyLabel( nm )
{
var val;
switch( nm ) {
case "email_address":
val = 'Email';
break;
case "email_message":
val = "Message";
break;
// etc.
default:
// just incase you missed a label
alert( 'Unhandled label: ' + nm );
}
return val;
}
Then wherever you see this:
+nm+
You replace it with
+returnUserFriendlyLabel(nm)+
精彩评论