How could i return user to unfilled field when he push “submit” button?
I have something like this:
<!--Contact Name-->
<div class="section" id="inputdiv">
<span class="fieldname">Name:</span>
<input type="text" id="contactname" /> <!-- Nessesary to be filled-->
<script type="text/javascript">
var contactname = new LiveValidation('contactname');
contactname.add(Validate.Presence);
</script>
</div>
<a class="button-more" style="width:903px; float: right; font-size: 15px; margin-top: 15px;" href="">Submit my answers</a>
Or just this:
<input type="text" id="contactname" /> <!-- Nessesary to be filled-->
<a href="">Submit my answers</a>
Form validation shouldn’t happen only in the front with HTML and JS since it’s too easy to bypass. You should also do some checks in your backend.
That being said, you’ll need to actually have a form in order to check correctly its validity. For instance:
then
I used jQuery syntax, but it’s basically the same thing with normal JS.
If you could also use all the nice plugins out there like http://bassistance.de/jquery-plugins/jquery-plugin-validation/
If you don’t want a form, just do a test on click on the submit link and test the value here.