JavaScript - How to validate a lookup field in sharepoint 2010 with javascript pre save() function

Asked By Bookworm on 28-Jun-12 08:27 AM

i have a LOOKUP field "CITIES" in a sharepoint list.
I need to validate this field: for example: if (CITIES.selectItem.value=="Viena" ) than .....//code

i build a preSave() function in javascript , and put it into newform.aspx.
but i dont know how to make the validation.

if you have any idea pls share because it is very urgent to me and i have been stuck on it for few days.

thnx in advance
[)ia6l0 iii replied to Bookworm on 28-Jun-12 12:32 PM
Should be a two-step procedure. 

a) Add the custom function to the loadfunctionames.

b) And add the validation in the newFunction();
function newFunction()
//select the Select element and check the value.

Hope this helps.

Bookworm replied to [)ia6l0 iii on 29-Jun-12 03:07 AM
the validation is the problem that i can not resolve, because the field is lookup type.

and i dont know how to get the item that is selected from user.