Menu

Requied field error messages in form

Help
2010-05-31
2013-06-03
  • Narendra Sarode

    Narendra Sarode - 2010-05-31

    Please anyone help to show error messages as per the name of the field. as per given link when user hit submit without filling required field message show "field mark with * required" . I need to show message for all required field and/or one or two field filled showing error message for remaining required field.

    http://www.vagmi.com/ndim1573/ndim-alumni.html

     
  • TNTEverett

    TNTEverett - 2010-06-01

    All fields are checked at the bootom of the form.html using javascript. 
    function validatePage1()
    {
    retVal = true;
    if (validateField('field_1','fieldBox_1','checkbox',1) == false)
    retVal=false;
    if (validateField('field_2','fieldBox_2','radio',1) == false)
    retVal=false;
    if (validateField('field_3','fieldBox_3','checkbox',1) == false)
    retVal=false;
    if (validateField('field_4','fieldBox_4','checkbox',1) == false)
    retVal=false;
    if (validateField('field_5','fieldBox_5','textarea',0) == false)
    retVal=false;

    if(retVal == false)
    {
    alert('Please correct the errors.  Fields marked with an asterisk (*) are required');
    return false;
    }
    return retVal;
    }

    In this case all fields 1-5 are checked and the one message is displayed for any error.  You can divide this up into individual checks for each field with messages for each field if you wish. 
    Note the validate function call.
    validateField('field_4','fieldBox_4','checkbox',1)
    The "1" at the end means "check this field.  A zero means "don't check this field".  Also note that some field types do not have working check functions.  This was not an oversight.  It was intentional and intended to be in the next release.  Unfortunately the next release is still a long ways away. 

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.