tomms Posted December 27, 2006 Share Posted December 27, 2006 Firstly, seasons greeting, hope everyone is closing out the year with style....Down to business.... I am trying to create a real time form validator much like Ibegin ([url=http://www.ibegin.com/register/]http://www.ibegin.com/register/[/url]), if you notice once you fill out one of the inputs it will immidiatly give you either an "okay" or an error message next to it.This is done with javascript and is pretty sraight forward, however the username and password are also checked against the database for duplicates (try to input "tomms" in username to see example). This is done through file called "register.php. I do have a database set up, and it is populated by a similar member signup form. However, i need some help writing the register.php file. I do have some coding background but am a relative newbie to Php, any help would be appreicated.The javascript....[code]<script type="text/javascript">function checkusername() { var username = document.register.username.value; if (username.length < 4 || username.length > 25) { if (username.length < 4) { document.getElementById('usernamecheck').innerHTML="<font style=\"color: red\">Username must be at least 4 characters</font>"; document.getElementById('username').style.border='red 1px solid'; } else { document.getElementById('usernamecheck').innerHTML="<font style=\"color: red\">Username cannot be longer than 25 characters</font>"; document.getElementById('username').style.border='red 1px solid'; } } else { LoadIntoElementRegistration('register.php?action=check&username='+username,'usernamecheck','Checking ...', 'username'); }}function checkemail() { var email = document.register.email.value; if (email.length < 6 || email.length > 49) { if (email.length < 6) { document.getElementById('emailcheck').innerHTML="<font style=\"color: red\">Email is too short</font>"; document.getElementById('email').style.border='red 1px solid'; } else { document.getElementById('emailcheck').innerHTML="<font style=\"color: red\">Email cannot be longer than 50 characters</font>"; document.getElementById('email').style.border='red 1px solid'; } } else { if (check_email(email)) { LoadIntoElementRegistration('register.php?action=check&email='+email,'emailcheck','Checking ...','email'); } else { document.getElementById('emailcheck').innerHTML="<font style=\"color: red\">Invalid email</font>"; document.getElementById('email').style.border='red 1px solid'; } }}function check_email(e) { ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM"; for(i=0; i < e.length ;i++){ if(ok.indexOf(e.charAt(i))<0){ return (false); } } if (document.images) { re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/; re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; if (!e.match(re) && e.match(re_two)) { return (-1); } } }</script>[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted December 27, 2006 Share Posted December 27, 2006 You'll want to make an AJAX call to your php file. Check out javascript frameworks like Mootools or script.aculo.us. Quote Link to comment Share on other sites More sharing options...
emehrkay Posted December 27, 2006 Share Posted December 27, 2006 ajax which is javascript and xmlonblur of formfield, that info is sent to the server adn something is returned to the page. there is a a subform on it 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.