forms - PHP - Empty field error handling -
i have form create account , redirects php page check form empty fields , insert data.
i'm using empty();
check if fields empty , error handling use echo, question if can in better way, because php form check page not have design applied error handling on blank page.
assuming fields in form input text fields (add class "requiredfield") these.make submit button disabled empty form loads.
jquery :
$(document).ready(function() { $("input.requiredfield:text").bind("keyup change", function() { updatesavebutton(); }); }); function updatesavebutton() { if ( $(".requiredfield:text").filter(function() {return $(this).val().match(/^\s*$/);}).length) { $("#submit").button({ disabled : true }); } else { $("#submit").button({ disabled : false }); } }
submit id of submit button , button part of jquery ui. if not using jquery ui add disabled attribute . eg:
$("#submit").attr("disabled","disabled"); {to add disabled attribute} $("#submit").removeattr("disabled"); {to remove disabled attribute}
since submit button remain disabled, user not able submit form. submit button remain disabled when user enters spaces values of text field
Comments
Post a Comment