views:

35

answers:

4

I'm selecting a form that doesn't have the name "someform", like this:

 $("form[name!=someform]").bind("keyup", function(e){
               [some code]
 }); 

What if I want to select a form that doesn't have multiple names, like "someform1" or "someform2"?

How do I do that?

A: 

Im afraid you have to make that distinction before you handle the rest of the code.

Depending on the situation you can always make an exeption for something thats radically different to the rest of your system.

Anyway, make an array, check if the array contains the formname.

Pokepoke
+1  A: 

Just supply multiple attribute selectors.

$("form[name!=someform1][name!=someform2]").bind("keyup", function(e){ [some code] });

Although it would be easier to apply classes to distinguish different forms and use those.

$("form.ajax-form").bind(...);
tvanfosson
thx for helping a n00b out! :)
timkl
A: 

You can either use another attribute like it's id or class or you can use the element itself:

If you have one:

$("form").bind(("keyup", function(e){
    [some code]
});

Or with more than one:

$("form:eq(0)").bind(("keyup", function(e){ //eq is the form index you're selecting
    [some code]
});
jeerose
A: 

http://api.jquery.com/not/

$('form').not('form[name=someform] form[name=someform2]').bind( ... )
Cryo