Ensure that form never submits without using javascript or jquery -
i have situation using custom jquery plugin hijack form submit. data in form sent via jsonp cross domain ajax call server. data cannot ever posted sever hosting form.
my problem if client has javascript disabled, plugin won't prevent form submitting. how ensure form doesn't ever submit without javascript enabled?
one option have considered use javascript write out form tags.
<script type="text/javascript"> document.write('<form id="myform">'); </script> <!-- form html here --> <script type="text/javascript"> document.write('</form>'); </script>
and apply plugin form
$('#myform').myplugin();
while work, seems kind of hacky, considering third party clients going using plugin , i'd rather not dictate forms have written way. possibility if had go way force them attach plugin div containing form , auto-inject form tags around div , continue normal. tells me, however, there has easier way.
if you're not ever going standard form submit, eliminate <form>
tags altogether replacing them <div>
tags. need tie submit valid element, such span. , $('#mydiv').myplugin();
Comments
Post a Comment