Total members 11890 |It is currently Fri Apr 19, 2024 3:54 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : [Ajax/PHP] Registration - Check for empty textboxs
 Check empty string     -  
 check empty number     -  
 lesson6: XSD Complex Empty Elements     -  
 Registration page in jsp     -  
 Use ActiveX without registration     -  
 php user registration system     -  
 HTML registration form example     -  
 php User Registration Form     -  
 What is AJAX, How to start AJAX?     -  
 complete registration form with validation     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com