Finally fixed popup validation