Copy link to clipboard
Copied
I have a form that submits to itself, validates data, manipulates data if no errors are detected and redirects to another page to confirm the action to the user. If an error is detected, it will show them above the form.
In this case, the form submits to a hash tag (internal anchor) to forward the user to the errors instead of having to scroll.
The issue is that during redirection, the hash tag is added to the destination URL. Here is my test case:
<!DOCTYPE html>
<head>
<title></title>
</head>
<body>
<cfif StructKeyExists(form, "doRedirect")>
<cfif form.doRedirect eq 1>
<cflocation url="http://adobe.com" addtoken="false">
<cfelse>
<div id="errors">
<ul>
<li>Some error could have occured here.</li>
</ul>
</div>
</cfif>
</cfif>
<form action="#errors" method="post">
<div><label for="doRedirect">Do Redirect?</label><select name="doRedirect" id="doRedirect"><option value="0">No</option><option value="1">Yes</option></select></div>
<div><input type="submit" value="Go"/></div>
</form>
</body>
</html>
Have something to add?