Fsoft Posted July 21, 2009 Share Posted July 21, 2009 Hello sir/madem , <form method="POST" action="login.php"> <p align="center">username : <input type="text" name="T1" size="20"></p> <p align="center">password : <input type="password" name="T2" size="20"></p> <p align="center"><input type="submit" value="Submit" name="B1"></p> <p align="center">Username and password can't contain less than 6 chars.</p> </form> Using this code, I made a form which contains username and password field. The only problem is that I don't wan't submit button to submit info to my php file until it verifies that the username and password contains more than 6 chars and (or) is not blank. I can do this verifiction in my php file, but the only problem is for that it will take time as will submit info to php file and then wait for the answer and so on.. I can do this with some really simple javascript integrated in same page??? I have 0% knowledge of Javascript please help me with this.. Some thing really very simple so that I can learn that easily also.. Thanks a lot, Faisal Link to comment https://forums.phpfreaks.com/topic/166774-modifying-info-before-submit/ Share on other sites More sharing options...
dzelenika Posted July 21, 2009 Share Posted July 21, 2009 try this http://www.w3schools.com/jS/js_form_validation.asp Link to comment https://forums.phpfreaks.com/topic/166774-modifying-info-before-submit/#findComment-879425 Share on other sites More sharing options...
seventheyejosh Posted July 21, 2009 Share Posted July 21, 2009 try: //javascript <script type="text/javascript"> function check(){ if(document.getElementybyId('username').value.length<6){ alert('Username Must Be At Least 6 Characters Long!'); return false; }//end if if(document.getElementybyId('password').value.length<6){ alert('Password Must Be At Least 6 Characters Long!'); return false; }//end if document.myform.submit(); return true; }//end function </script> //form <form method="POST" action="login.php" name="myform"> <p align="center">username : <input type="text" name="T1" id="username" size="20"></p> <p align="center">password : <input type="password" name="T2" id="password" size="20"></p> <p align="center"><input type="submit" value="Submit" name="B1" onclick="return check();"></p> <p align="center">Username and password can't contain less than 6 chars.</p> </form> lemme know Link to comment https://forums.phpfreaks.com/topic/166774-modifying-info-before-submit/#findComment-879465 Share on other sites More sharing options...
Fsoft Posted July 21, 2009 Author Share Posted July 21, 2009 try: //javascript <script type="text/javascript"> function check(){ if(document.getElementybyId('username').value.length<6){ alert('Username Must Be At Least 6 Characters Long!'); return false; }//end if if(document.getElementybyId('password').value.length<6){ alert('Password Must Be At Least 6 Characters Long!'); return false; }//end if document.myform.submit(); return true; }//end function </script> //form <form method="POST" action="login.php" name="myform"> <p align="center">username : <input type="text" name="T1" id="username" size="20"></p> <p align="center">password : <input type="password" name="T2" id="password" size="20"></p> <p align="center"><input type="submit" value="Submit" name="B1" onclick="return check();"></p> <p align="center">Username and password can't contain less than 6 chars.</p> </form> lemme know The code seems to be simple and it is.. but it is not working Please can you have a look on it? Link to comment https://forums.phpfreaks.com/topic/166774-modifying-info-before-submit/#findComment-879762 Share on other sites More sharing options...
seventheyejosh Posted July 21, 2009 Share Posted July 21, 2009 look at what. do you have a link for me? or an error? or shall i emulate it with my mind. Link to comment https://forums.phpfreaks.com/topic/166774-modifying-info-before-submit/#findComment-879835 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.