Forums

This topic is locked

Custom Validation error.

Posted 25 Jul 2003 22:08:16
1
has voted
25 Jul 2003 22:08:16 shumon h posted:
I have a form that has text fields. I am using MX's validation feature. I checked required and numbers. Now, when some enter a letter the error message pops up. Good! Now, how can I customize that error message to something else, instead of having the default set my MX?

Wanna be WebDESIGNER

Replies

Replied 28 Jul 2003 00:22:12
28 Jul 2003 00:22:12 Claus Olsen replied:
Hi.
You need to go into your codeview, and find a section like this:

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="" {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' er ikke en valid e-mail adresse.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' må kun indholde tal.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' skal indeholde et tal mellem '+min+' og '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' er obligatorisk.\n'; }
} if (errors) alert('Følgende fejl opstod:\n'+errors);
document.MM_returnValue = (errors == '');

Here you can change the text in the error boxes.
SUT

Reply to this topic