This discussion is archived
6 Replies Latest reply: Oct 12, 2012 6:13 AM by 665735 RSS

Country Name exists or not in Jquery!!

665735 Newbie
Currently Being Moderated
Hi All,

I want to validate country filed in Jquery, when the users clicks the filed if that country does not exists in database then the validation should throw error.
Below is the script i had wriiten when the submit button is pressed. Now how to handle those error messages in the below script.
--
function validateCTRY(){ 
                var data=$.data(P1_ENG_CTRY); 
                if (data.autocomplete.selectedItem)
                {
                                if(data.autocomplete.selectedItem==undefined)
                                {
                                                invalidModel = true;  //error scenario
                                }
                                else
                                                $(P1_ENG_CTRY).css("background-color","#FFFFFF"); //success scenario
                }
                else
                {
                                invalidModel = true; //error scenario
                }
}
Thanks,
Anoo..

Edited by: Anoo on Sep 28, 2012 12:22 AM

Edited by: Anoo on Sep 28, 2012 3:59 AM

Edited by: Anoo on Sep 28, 2012 6:00 AM

Edited by: Anoo on Sep 28, 2012 6:09 AM

Edited by: Anoo on Sep 28, 2012 6:10 AM
  • 1. Re: Country Name exists or not in Jquery!!
    665735 Newbie
    Currently Being Moderated
    Hi Team,

    Any help on this request please!!

    Thanks,
    Anoo..
  • 2. Re: Country Name exists or not in Jquery!!
    AlistairLaing Explorer
    Currently Being Moderated
    Firstly, you dont have valid jQuery Selectors $(P1_ENG_CTRY) should be $('#P1_ENG_CTRY') if you have a page item with an id of P1_ENG_CTRY

    Do you have more code?
  • 3. Re: Country Name exists or not in Jquery!!
    665735 Newbie
    Currently Being Moderated
    Hi Alistair,

    Thanks for the inputs..I had made changes as requested but it is not displaying any alert messaage.Here is the updated one.
    The function will be called when i click on Submit button. No additional code exists..
    --
    function validateCTRY(){ 
                    var temp=$.data('#P1_ENG_CTRY'); 
    
    alert("Thhe e value of country is:"+temp);
                    if ( temp.autocomplete.selectedItem)
                    {
                       if(temp .autocomplete.selectedItem==undefined)
                       {
                          invalidModel = true; 
                       }
                         else
                       $('#P1_ENG_CTRY').css("background-color","#FFFFFF");
                      }
                    else
                    {
                                    invalidModel = true; //error scenario
                    }
    }
    Thanks,
    Anoo..
  • 4. Re: Country Name exists or not in Jquery!!
    AlistairLaing Explorer
    Currently Being Moderated
    Can you post the script that you are using to bind this function or setup a simple example on apex.oracle.com workspace?
    By the sounds of things its simply not being called but I cant tell why its failing from the code that you provided.
  • 5. Re: Country Name exists or not in Jquery!!
    665735 Newbie
    Currently Being Moderated
    Hi,

    I will post an example shortly..

    thanks,
    Anoo..
  • 6. Re: Country Name exists or not in Jquery!!
    665735 Newbie
    Currently Being Moderated
    Hi Alistair,

    At last i could able to figure it out and could able to run the same.. But i had another problem the thing is i had nearly 9 autogen items where i had hadnled the funcation as mention below..Asumming i had enter only first two fileds and rest are empty but it is triggring for all the rest of items.
    How we can handle this scenerio...Any help on this below code..
    --
    var validPlattsPopupLead=true;
    function validatePlattsPopupLead()
    { 
    
         $("#P3_ENG_PART1").add("#P3_ENG_PART2").add("#P3_ENG_PART3").add("#P3_ENG_PART4").add("#P3_ENG_PART5").
         add("#P3_ENG_PART6").add("#P3_ENG_PART7").add("#P3_ENG_PART8").add("#P3_ENG_PART9").each(function()
         {
              var data=$.data(this); //this -> should be the object or Text box element
              if (data.autocomplete.selectedItem)
              {
                   if(data.autocomplete.selectedItem==undefined)
                   {
                        validPlattsPopupLead = false;  //error scenario
                        $(this).css("background-color","#FF0000");
                        alert("Value selected is not present autocomplete!!!");
                   }
                   else
                   {
                        $(this).css("background-color","#FFFFFF"); //success scenario
                        alert("Value selected is present in autocomplete!!!");
                        validPlattsPopupLead = true;
                   }
              }
              else
              {
                              validPlattsPopupLead = false; //error scenario
                   $(this).css("background-color","#FF0000");
                   alert("Two Value selected is not present  autocomplete!!!");
              }
         });
         return validPlattsPopupLead;
    }
    Thanks,
    Anoo..

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points