I have a very small jQuery script that I would like to add to a single page. I am trying to add it directly in the page via the page editor in the Wordpress backend. Since it is so small and does not apply to any other page on my site, I would prefer to add it to the page directly. So, in the page editor I click on the 'Text' tab and include the following:
<script type="text/javascript">
$("form").submit(function( event ) {
if($('#somecheckbox').is(':checked')) {
alert( "Handler for .submit() called." );
}
else {
event.preventDefault();
}
});
</script>
<form action="/helpdesk/" method="post">
<input id="somecheckbox" type="checkbox" value="yes" /> <label for="somecheckbox">Checkbox</label>
<input type="submit" value="Submit" />
</form>
This doesn't work though and so I am wondering if it's even possible. Problem is that the alert box doesn't pop up and the submit doesn't get cancelled either.
I know how to include the script as a .js file, just hoped I didn't have to.