Validate dropdown if value is not null

I’m trying to figure out how to use the onCustomValidation event to mark a dropdown as valid or not, depending if an option has been selected. Here is the code I’m working with:

$w.onReady( function () {
$w(‘#dropdown3’).onCustomValidation(() => {
if ($w(‘#dropdown3’) !== null ) {
$w(‘#dropdown3’).validity.valid = true ;
$w(‘#dropdown3’).validity.valid = false ;

I’m not experienced at all with Javascript, so I imagine my issue is due to my ignorance. I’ve tried variations on that code, using the template for email verification from Wix (, but I can’t seem to figure out how to apply it to my situation.

When I preview the page, the dropdown starts as valid, but if I manipulate it in anyway, it changes to invalid (border changes red). I’m guessing it’s not understanding that I want it valid when any option other than the default (null) is selected.

Hey, Can someone reply on this thread, I am encountering same issue.


Please add a new post rather than bumping up an old post from 2018, add a link to refer back to this post if needed, along with any code that you have used in a code block.