November 23, 201015 yr Hey all, I found a handy script that stops form fields form being sent blank, Ive used it on a website and it works fine, Ive just used it again on this form and it wont work! Grrrr The script is below, it works fine on the other site, and throws up a window if a field is left blank.... <script type="text/javascript"> function validate_required(field,alerttxt) { with (field) { if (value==null||value=="") { alert(alerttxt);return false; } else { return true; } } } function validate_form(thisform) { with (thisform) { if (validate_required(Width,"Width must be filled out!")==false) {Width.focus();return false;} if (validate_required(Height,"Height must be filled out!")==false) {Height.focus();return false;} if (validate_required(Name,"Name must be filled out!")==false) {Name.focus();return false;} if (validate_required(Address,"Address must be filled out!")==false) {Address.focus();return false;} if (validate_required(Town_City,"Town/City must be filled out!")==false) {Town_City.focus();return false;} if (validate_required(Postcode,"Postcode must be filled out!")==false) {Postcode.focus();return false;} if (validate_required(Phone,"Phone must be filled out!")==false) {Phone.focus();return false;} if (validate_required(Email,"Email must be filled out!")==false) {Email.focus();return false;} } } </script> Thanks G
November 23, 201015 yr Pretty sure "width" is a reserved keyword, try changing the name to something else
November 23, 201015 yr Actually, it is likely to be this http://screenshots.jaygilford.com/2010-11-23_1154.png There is a gap/space after Width for the id
Create an account or sign in to comment