SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2001
    0 Post(s)
    0 Thread(s)

    Validate form - change pop up statements?

    I use Dreamweaver for my sites. I use the Validate Form behavior to reject the submission of the forms if certain fields haven't been completed.

    I have to title the name field "realname" so that it shows up properly in the emails I receive when the form is submitted. But if they don't fill in that field, then try to submit, the pop up says "realname is required".

    Is there any way to change the title in to pop up (to something more user friendly like: "You must fill in your name"), while leaving the field named "realname".

    Here is a link to one of my forms.


    Thank you,


  2. #2
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Clearwater, FL
    0 Post(s)
    0 Thread(s)
    The easiest thing to do is change the name of your form field from realname to Name. Other than that, you will have to rework your javascript.

    You can also edit your existing Javascript to display a more user-friendly error message

    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) {; if ((val=val.value)!="") {
    	  if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
    		if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
    	  } else if (test!='R') {
    		if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
    		if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
    		  min=test.substring(8,p); max=test.substring(p+1);
    		  if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    	} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
      } if (errors) alert('The following error(s) occurred:\n'+errors);
      document.MM_returnValue = (errors == '');
    You can change this line

    else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }

    to something like

    else if (test.charAt(0) == 'R') errors += 'You must enter a '+nm+' .\n'; }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts