Sorry, but brain is dead need help with alerts

Sorry, but brain is dead need help with alerts

I hope i placed in the correct sub forum.
 
Its been a little while since i had to update my form and having some issues.  I have it set up for a 'coordinates' field, with the format as ###|### (#=number).  I have an alert to pop up if they input the coordinates wrong.  I am also trying to have an alert pop up if the new coordinates are already entered.
 
I do have it checking for dup's and will give an error like: 'invalid entry for key2' ... What i would like is for it to compare to DB and if already entered to have an alert popup with 'this settlement is already claimed'.  I have the first alert working (for the coordinate format), but for some reason i get the 'this settlement is claimed!' pop up on every entry. 
 
I cannot figure out how to have it compare the input.coordinates to the DB.  Here is my script (i know its real messy, but was trying everything to make it work late last night.
 
'Copy_of_Realmz_Elite_Claimz_Form' is the form im working on (although i'd like on either one - the copy is so i dont mess up the current one).
 
In the 'on validate' and also in the 'coordinates, on user input', so that it can pop up the alert if a duplicate before submitting.  Im big time n00b w/this scripting, so sorry for my rookie question(s).  I have allowed support access JIC.. as im afraid i've added 1 too many places, but dont know as the 2nd alert always pops up.  :(
 
 
Here is what i have in both places... the top script works fine (thnx to support):

  1. myRegExResult=(input.Coordinates).replaceAll("[0-9][0-9][0-9](\|)[0-9][0-9][0-9]","");
  2. if((myRegExResult != ""))
  3. {
  4.     alert "Please Enter the Number as Coordinates: ###|###!";
  5. }
  6. if((input.Coordinates == myRegExResult))
  7. {
  8.     alert "This settlement is already claimed!!";
  9. }


The 'myRegExResult' i tried last, just for the fun of it.. I have tried all the variations of input.coordinates, etc that i can find to try in its spot.  Seems i cannot get it to compare to DB, just to what is entered (which will always give alert).  Ha, probably messing up my form testing different variations, but is why im using the copy. :)