开发者

jQuery not working with ASP.NET form!

I have built a web form with some tables and custom controls inside it, and now I would like to provide a button to clear all the fields (radio buttons included). Since I had never worked with jQuery before, and since I read somewhere it can save a lot of work and has a consistent behaviour with most browser, I thought about using it with the jquery.form.js plugin to clear the form in an easy way. I renamed the form to

<form id="someForm" action="~/Default.aspx"> (...) </form>

and on the OnClientClick event of the button I wrote

$form('#someForm').clearForm();

The problem is that nothing really happens... jQuery is properly referenced, since

开发者_StackOverflow$(document).ready(function() { alert('Test'); });

shows the alert dialog properly, but the previous command doesn't really do anything. Then I tried using the standard

document.forms[0].reset();

and it works fine. I know about the "problems" with this command, since it doesn't really clear all the fields but rather resets it to their original state... In the particular case of this form the two effects are really the same, but I would like to know why jQuery is not working in the case of this form. Does anyone have any ideas?


It should be: $('#someForm').clearForm();


just the duplicate of answer by scrappedcola

$('#someForm').clearForm();

is the way to select the form by id see jquery selectors

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜