0

I am using Jquery Mobile, Jquery. I have three data-role="page". I have three different ID for three different pages. Now I need to validate multiple fields which is there in 2nd data-role="page".

In the second page, i have static dropdowns and some text boxes. On selection of the dropdown i am displaying some more fields into the page. On button click i need to validate the newly displayed fields.

if (LOCATIONOne_Sel_Val=='')
    {
        if($('#errorLocOne').length) 
        {
            return false; //If the error Message is displayed already
        }
        else //Display the error message
        {
            $(errorMsgLocOne).insertAfter('#Loc_Id1');
            return false;
        }
    }
else if(LOCATIONTwo_Sel_Val=='')
    {
    if($('#errorLocTwo').length) 
        {
            return false; //If the error Message is displayed already
        }
        else //Display the error message
        {
            $(errorMsgLocTwo).insertAfter('#Loc_Id2');
            return false;
        }
    }

In the above code, If i select some value in LOCATIONTwo_Sel_Val dropdown then one more drop down will be displayed. I need to validate that too for a null Value.

Like this i have 15 fields to validate. How can i achieve this in a better way?

NOTE: I am not using Validation plugin. Dont want to use that.

Ramesh
  • 8,921
  • 3
  • 18
  • 14

0 Answers0