jQuery-MultiSelect icon indicating copy to clipboard operation
jQuery-MultiSelect copied to clipboard

How to validate for requirement?

Open nordicblue opened this issue 2 years ago • 1 comments

Hi!

First and foremost, thank you for all your work on this project. I love how it's coming together.

Unfortunately, I am stuck understanding how requirement validation works for your code. The default client side validation does not work, since the code hides the original select to create the new one and therefore you cannot apply the normal "oninvalid" to the field. I'm not sure, how on form submit, I could check the field's value using JS.

I also tried to setup server side validation, as I do both to ensure validation never fails, by checking the field's value on POST. But, unfortunately, the field is omitted from post when no value exists. Unfortunately, it's not easy for my dynamic form to simply see if the field name is in the POST data, or not, and mark as no value if no field exists in POST.

So, I'm looking for a way to validate requirement client side, via JS or JQuery, and see how I can get the field to post with a blank value when no values are selected.

Let me know if I'm just missing something simple and thanks a million for your help.

Thanks!

nordicblue avatar Nov 11 '23 15:11 nordicblue

There isn't a way to do it in the manner you are describing. The best thing I can think of is to write some custom validation when the form is submitted and either error or let the submission continue based on your requirements.

I can't imagine a server side language that you cannot test if a value exists in the POST. Not knowing more I cannot provide anymore potential insight. But from a security/data integrity side of things you should ALWAYS validate server side. Client side is just a quick check to make sure things are accurate but since its client side its easy to bypass.

nobleclem avatar Nov 15 '23 17:11 nobleclem