zed420 Posted November 4, 2008 Share Posted November 4, 2008 Hi ALL Can anyone tell me how can I use alert error messages without wiping out all the information that user has put in. eg. I have a form if user makes mistake inserting his/her password an error messages pop up (alert box) but it wipes out rest of the form too. Is there any way I can keep rest of the inserted information. Thanks Zed Quote Link to comment Share on other sites More sharing options...
Andy-H Posted November 4, 2008 Share Posted November 4, 2008 <input type="text" name="username" value="<?php echo $_POST['username']; ?>" > Quote Link to comment Share on other sites More sharing options...
peranha Posted November 4, 2008 Share Posted November 4, 2008 Add this to your form onsubmit="return loginCheck(this)" you can change the below to what you need. change username to what you want it to check. the name of the input. This will run when the submit button is hit. function loginCheck() { var username = document.login.username; if (username.value.length < 1) { alert("Enter a User Name."); return false; } else { if (username.value.length > 25) { alert("Enter a User Name up to 25 characters."); return false; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.