SharePoint - javascript how to validate llokupfield in new form

Asked By Bookworm on 25-Jun-12 11:24 AM
i need to do a validation, a lookupfield "field1", has some items, and i want  when user that is adding new item, select the "counting" choice, an alert to be shown.
i dont know how to do this for look up fields, i have created a new form.

and im using this: var var1 = getTagFromIdentifierAndTitle("SELECT","Lookup","field1");

if you have any idea pls share because it is very urgent to me!

Jitendra Faye replied to Bookworm on 26-Jun-12 12:42 AM
The code which you are using that will work for normal control  but if you are using LookupField  then try something like this-

Try like this-

var cons = document.getElementsByTagName("select");
for (var i = 0; i < cons.length; i++) {
if (tags[i].title == "field1") {
//your code

TRy this and let me know.
Bookworm replied to Jitendra Faye on 26-Jun-12 03:23 AM
it does not work.....
can you explain better pls??? fiel1 is the name of field lookup type.
Bookworm replied to Jitendra Faye on 26-Jun-12 04:33 AM
pls i need to get the selected item of field1

if you can help me with the section " //your code "

thnx in advance