0

Hi Guys

i have a formValidation Java Script on the form to validate username and password
text boxes to check whether they are empty,and i am calling them on the Onclient Click
even ton the button, But even If i enter some data into those text boxes the error message
alert appears, what it the problem with my code here ?

`<script type="text/javascript">

function FormValidator() 
{
    if (document.getElementById('txtusername').value == "");
    {

        alert('Invalid User Name');

    }


     if (document.getElementById('txtpassword').value == "");
     {

        alert('Invalid Password');

    }


}

</script>
`

thanks
regards
sumith

4
Contributors
5
Replies
22
Views
3 Years
Discussion Span
Last Post by AndrisP
0

how we can a field validate from database? like when i enter in user abc it validat from database whether valid or not?

0

In HTML5 you can use attribute "required" to <input type="text" required="required" /> and <input type="password" required="required" /> instead of your js function

0

i thin u not pick my point. i want to validate a field whether a valid user mean when i enter in user fied abc whether this abc is in the database table or not if yes then ok othere wise it give alert.....

0
var txtusername = document.getElementById('txtusername').value;
$.post('index.php',{isitinDB:txtusername},
    function(data){return data;});

and index.php

<?
if(isset($_POST['isitinDB'])){
    /* check in db $_POST['isitinDB'] and return true or false */
    exit();
    }

?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.