Search code examples
phpjoomla

Seblod Search on Empty Field (Exact Match)


I have a List & Search Type form that has only one input field called Username. I have set it to Exact matching, so it only returns back results if an exact match is found.

But if the Username field is empty and I hit enter, it returns with all the results, whereas it should not get back anything as the field is empty. This might be a trivial problem but I'm really new to Seblod and Joomla.

I have tried most of the other options in Match+Stage and Conditional States options, but I still get back all results on empty search as well.


Solution

  • I tried a lot of permutations and combinations with Seblod Field Validations but it won't do what I wanted it to do.

    But this is how I finally solved it- I created a new 'Field' in Seblod and set it's type to Script(JS), which basically creates a JS file for us that can be used with any form/list search. Now to connect this JS file with my form, I added this newly created 'Field' as a Hidden Field on my form. Then it was as simple as adding preventDefault() and return false; on form submission inside the JS.