In the form template you need to make sure that you have the value fields filled in with if tags - for example:
<input type="text" name="Surname" value="<%if Surname%><%Surname%><%endif%>"/>
and then in the script that is processing the form, make sure that you feed the variables back in when you display the error template - for example:
print Links::SiteHTML::display('template_name', { %$variables, main_title_loop => $mtl, error => $error });
<input type="text" name="Surname" value="<%if Surname%><%Surname%><%endif%>"/>
and then in the script that is processing the form, make sure that you feed the variables back in when you display the error template - for example:
print Links::SiteHTML::display('template_name', { %$variables, main_title_loop => $mtl, error => $error });