2009-10-09 40 views
0

我在頁面上使用不同的ID有幾種形式,我想知道哪些是提交和它的ID。我怎樣才能做到這一點?識別使用JQuery提交的表單

//stop all forms from submitting and submit the real (hidden) form#order 
$('form:not(#order)').submit(function(event) { 
event.preventDefault(); 

上述停止所有形式提交,我會把像在有條件的說,如果這種形式,那麼這樣做等

讚賞任何幫助。

感謝所有

回答

2
$('form:not(#order)').submit(function(event) { 
    if ($(this).attr('id') === 'someId') { 
     event.preventDefault(); 
    } 
}); 
1
$('form').submit(function(event) { 

    switch ($(this).attr('id')) { 
     case 'contact': 
      alert('contact us'); 
     break; 

     case 'order': 
     break; 

     default: 
      event.preventDefault(); 
     break; 
    } 


} 


assuming all your form els have IDs.