waseem02 / jquery-asmselect

Automatically exported from code.google.com/p/jquery-asmselect
0 stars 0 forks source link

ASM Select + Form Validation #13

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This isn't an issue with asm select, I just didn't know where else to ask. 

I just want a user to not be able to submit a form if something isn't
selected with asm select. Any easy way to do that (or check if something
has been selected)? I'm using jQuery validation, but it doesn't seem to be
compatible with asm select. By the way, this plugin in awesome.

Original issue reported on code.google.com by garrett...@gmail.com on 19 Feb 2009 at 5:19

GoogleCodeExporter commented 8 years ago
The way asmSelect works, it should not conflict with validation plugins (in 
theory
anyway). I think I'd need a working example to take a closer look. Would it be
possible for you to post an example that I could review?

Thanks,
Ryan

Original comment by ryancram...@gmail.com on 21 Feb 2009 at 4:04

GoogleCodeExporter commented 8 years ago
Thanks for getting back to me. Here is an example where the validation works on 
a
text input but not on the asm select.
http://gbanker.com/asm/examples/withvalidation.html

Here is the source:
http://gbanker.com/asm/asm.zip

Original comment by garrett...@gmail.com on 21 Feb 2009 at 6:39

GoogleCodeExporter commented 8 years ago
I'm not getting notified of messages here for some reason -- my apologies for 
the
delay. The links you provided don't appear to be working still, would it be 
possible
for you to post this again?

Thanks,
Ryan

Original comment by ryancram...@gmail.com on 29 Mar 2009 at 7:14

GoogleCodeExporter commented 8 years ago
Thanks, the links work again.

Original comment by garrett...@gmail.com on 29 Mar 2009 at 8:31

GoogleCodeExporter commented 8 years ago
I didn't have a problem getting the validate plugin working for my multiple 
select.  
However I did have a problem with it removing the validation message when I 
selected 
an item in the asm dropdown.

I think the problem with the code that you have is that the name is cities[] 
but in 
the validate rules/messages you refer to it as cities.

Below is a snippet of my code.

<select id="Codes" name="Codes" multiple="multiple" size="10" style="width: 
400px"></select>

var validator = $("#form1").validate
        ({
            rules:
             {
                Codes: "required",

             },
            messages:
             {
                Codes: "At least one repair code is required",
             }              

        });

Original comment by digitalD...@gmail.com on 1 Apr 2009 at 12:34

GoogleCodeExporter commented 8 years ago
Ah thanks. I got it working with the same problem you have now :)

http://gbanker.com/asm/examples/withvalidation.html

You can see that if you hit submit it gives you the 2 errors. If you add text 
into
the text box, it instantly updates but with asm it does not update when you 
select
something. It updates when you submit the form though.

Original comment by garrett...@gmail.com on 1 Apr 2009 at 12:54

GoogleCodeExporter commented 8 years ago
Thanks for looking into this stuff. I'm not really clear about whether this is 
an
issue with asmSelect, the validation plugin, or just the two of them together. 
I've
put it in the queue, but if you can let me know what version of the validation 
plugin
you are using, or if you've come across anything new in this regard. Thanks 
-Ryan

Original comment by ryancram...@gmail.com on 4 Jun 2009 at 3:16

GoogleCodeExporter commented 8 years ago
We have been experiencing the same problem with asm-selects not retriggering
validation when items are added/removed.  The issue is that by default, jquery
validator retriggers on the "focusout" event, whereas asmselect triggers the 
change
event.  For me, modifiying the "triggerOriginalChange" function in asmselect to
trigger focusout was the easiest fix, and created the most desirable effect.  I 
don't
see a way in jquery validator to validate onchange instead of focusout, which 
might
be a way to fix it on the jquery validator side.

Original comment by adam.lis...@gmail.com on 16 Jun 2009 at 2:52

GoogleCodeExporter commented 8 years ago
I came across this issue in a recent project and used the following soultion.  

I added the following code within a document ready to make sure the form 
re-validated
whenever an asmSelect object was changed.

$(".asmSelect").parent().find("select").change(function() {
      $(this).parents("form").validate().element(this);
});

It monitors the original select so that if you remove all the list items again, 
it
revalidates it.  It also only revalidates the asmSelect item as opposed to 
whole form.

Hope this helps.

Original comment by ja...@beautifulcoding.com on 27 May 2010 at 6:21

GoogleCodeExporter commented 8 years ago
Validators like jquery.validationEngine do not work with ASM because they do 
not by default check hidden elements.  The workaround is make the original 
select box (that ASM select hides) width:0px;height:0px;display:block;

Original comment by mark.bad...@gmail.com on 25 Oct 2012 at 11:54