ASAP solution for validation

I have two dropdown fields.one is category and another is subcategory.on the selection of category in lookup of subcategory,subcategories corrosponding to the category all ready selected subcategories lookup is coming…Now the problem is when i select a category and in subcategory if i type something which is not in the lookup,my subcategory field is holding the value…its not validating…

i have written this code…

public

boolean

validate()

{

boolean

ret;

LNT_CMMSSubCategoryTable cmmsSubCategoryTable = LNT_CMMSSubCategoryTable::findSubCategory(LNT_CMMSEquipmentTable.SubCategoryId);

ret =

super

();

if

(LNT_CMMSEquipmentTable.SubCategoryId != cmmsSubCategoryTable.SubCategoryId )

{

ret = checkFailed(

@LNT581

);

}

return

ret;