user4fun Posted October 30, 2007 Share Posted October 30, 2007 How difficult is it to set up a form like the high qulaity ones you see, When an error occures for missing data or invalid entry it would highlight it in red, or show the form again with the other field full and the one that is wrong has a text beside it that shows up.I dont want to make a seperate error form for every field. There might be a bunch of field, possible 15. Link to comment Share on other sites More sharing options...
Synook Posted October 30, 2007 Share Posted October 30, 2007 You mean form validation? Error trapping is for handling runtime errors.That form of smooth validation is likely to be done client-side, with JavaScript. It would be easy to have a <span> tag next to each form field that gets tested onsubmit of the form and then if invalid the JS script would write something int othe tag. A simple one-filed example: <script type="text/javascript"> function validate() { error = false; form = document.getElementById('form'); if (form.name == "") { document.getElementById('name_error').innerHTML = "Please enter a valid name"; error = true; } return error; } function clearelement(ele) { document.getElementById(ele).innerHTML = ""; }</script><form id="form" method="post" action="#" onsubmit="return validate()">Name: <input type="text" name="name" onfocus="clearelement('name_error')" /><span id="name_error"></span> </form> Link to comment Share on other sites More sharing options...
user4fun Posted October 30, 2007 Author Share Posted October 30, 2007 sweetthank you Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.