mflorence
Newbie
Posts: 1
Registered: 3/16/2005
Member Is Offline
|
| posted on 3/16/2005 at 05:24 PM |
|
|
Defining a function in a message template
I have defined a function in the message template to return a different error message than the default. I have this working but now I want to return
a different error message depending upon which form field has an error. I need to know which form field is being checked so that I can return the
proper error message.
Below is my code.
function validatemessage(theform)
{
if (document.forms[theform].price.value<2)
return '"%l%" cannot be less than 2.'
else
return '"%v%" is not valid value for "%l%"';
}
v1_config =
{
'alert' : 1,
'alert_class' : ['fieldtitlenotvalid', 'fieldtitle'],
'messages' :
{
'fill' : [
null,
function (theform){return validatemessage(theform);}
]
}
}
I want to return the less than 2 error message only for the price field and I want to return the other message for all other fields. If price is less
than 2, this code returns the less than 2 error for all fields.
How do I determine which field is calling my function?
|
|
|
|