Javascript: How to detect if the current page has a form with particular name and input

Viewed 752

I have a form which looks like this

<form action="/aa/bbcc" method="post" id="Form1" accept-charset="UTF-8">
    <input type="hidden" name="somename" value="somevalue" />
    ... other stuff
</form>

In a common $(document).ready(function() which is shared between multiple pages, I want to detect if I am in a page which has a form with the following characteristics

  • action="/aa//bbcc" & id="Form1"
  • an input with name="somename" and value="somevalue"

How do I do this?

The page has access to jquery also if that is required. Without jquery is also fine.

4 Answers
Related