Total members 10249 | Gratitudes |It is currently Thu May 17, 2012 6:54 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question subject: [Ajax/PHP] Registration - Check for empty textboxs
PostPosted: Sun Dec 25, 2011 4:23 pm 
Offline
Newbie
User avatar

Joined: Sun Dec 25, 2011 4:19 pm
Posts: 1
Has thanked: 0 time
Have thanks: 0 time

Hi,

I'm doing a registration system and as you can see when i verify the fields, if it's empty it says that the FIELD_1 misses. And what i want is if the field is empty says that and then goes back, but i don't wanto the info already written disappears.

I'm using ajax, i never worked with it, so i'm gonna ask you if i'm doing everything ok:

registration form:
Code:
    <!---------VALIDAÇÃO AJAX---------->
    <link rel="stylesheet" type="text/css" href="style_val.css" />
    <script src="ajaxforms.js" type="text/javascript" language="javascript"></script>
    <!--------------------------------->
    <div class="indent">
     
    <h2> Inscrição </h2>
     
    <form action="" method="post">
    <fieldset>
    <legend> ALUNO </legend>
     
    <br/>
    <div class="title" class="field"><label>Username*: </label><input type="text" size="30" name = "username" OnChange="CheckField(this)" tabindex="1"/></div>
    <div id="username" class="message"></div>


ajaxform:
Code:
    var AJAXForms = false;
    var LastField = null;
    var isIE = false;
    // on !IE we only have to initialize it once
    if (window.XMLHttpRequest) {
    AJAXForms = new XMLHttpRequest();
    }
     
    function CheckField(field) {
     
    if (window.XMLHttpRequest) {
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
    AJAXForms = new ActiveXObject("Microsoft.XMLHTTP");
    }
     
    AJAXForms.onreadystatechange = processChange;
    AJAXForms.open("GET", "check.php?op=ajax&field=" +field.name+"&value=" + field.value);
    LastField = field.name;
    AJAXForms.send(null);
    }
     
    function processChange() {
    if (AJAXForms.readyState == 4) {
     
    var res = document.getElementById(LastField);
    res.innerHTML = AJAXForms.responseText;
    res.style.visibility = "visible";
     
    }
    }


style:
Code:
    body,* {
    font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
    font-size: 12px;
    }
     
    .ajform {
    background: #FF7F50;
    border:1px solid black;
    padding: 4px;
    margin: 4px;
    width: 500px;
    }
     
    .title {
    width: 60%;
    background: #FFAF91;
    padding: 4px;
    }
     
    .field {
    padding: 4px;
    background: #FFE691;
    }
     
    .message {
    background: white;
    border:1px solid #FF7F50;
    visibility: hidden;
    margin: 4px;
    text-align: center;
    }
     
    .green {
    color: Green;
    }
     
    .red {
    color: red;
    }
     
    .category {
    background: #E0FF91;
    padding: 4px;
    }



Please help me.

Thank you,
PF2G


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 using ajax with asp
 AJAX SYNTAX ERROR IE
 Sending One lakh character in ajax
 Ajax Source code to Suggest application with JSP Server side
 lesson6: XSD Complex Empty Elements
 php User Registration Form
 complete registration form with validation
 Selecting a Domain Name at the Time of Registration
 check array contains a value using javascript
 can u check tis code to perform union & intersection of list

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team