문제

I have a client who really hates captcha but it is needed otherwise there are too many spam submissions. I had a person recommend the following:

Have your web form and only have the form action in a data tag (html5) and then on completion of the form and submit the form process actions that action in. No form action, no bot can fill it in and submit and no modification to how your form looks or operates.

If I have a form that looks like this:

<form action="/FormProcessv2.aspx?WebFormID=10090&amp;OID={module_oid}&amp;OTYPE={module_otype}&amp;EID={module_eid}&amp;CID={module_cid}" enctype="multipart/form-data" onsubmit="return checkWholeForm15174(this)" method="post" name="catwebformform15174">

How would I modify the action URL to use data-attribute? Would it require JS to function? How does the idea work?

Note: I searched Google and I could not find any information on using data-attribute and from action. Also I am using jQuery 2.0.3 on the site.

Any guidance is welcome.

도움이 되었습니까?

해결책

How it would work, on form submit (call this swapAction when your current checkWholeForm15174 validates)

function SwapAction() {
    var dataAttr = $('#myFormName').data();

    $('#myFormName').get(0).setAttribute('action', dataAttr.action);
}

assuming your form was modified to look like:

<form action="" data-action="/FormProcessv2.aspx?WebFormID=10090&amp;OID={module_oid}&amp;OTYPE={module_otype}&amp;EID={module_eid}&amp;CID={module_cid}"  enctype="multipart/form-data" onsubmit="return checkWholeForm15174(this)" method="post" name="catwebformform15174">
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top