0

hello
i have a form for registering the user and i use java script for client side check that the field is filled or not the problem is that when user not fill the first name and press register button it will show client side message that the first name must be filled and after the message it will go on next page and save the data into database. i want that the next page could not open if any field is empty please tell me the solution

waiting for your reply

3
Contributors
4
Replies
6
Views
5 Years
Discussion Span
Last Post by phoenix_2000
0

If you have "return false;" for the onclick event it cancels the postback. The following is a quick example.

function validate(){
    var blnIsValid = true;

    if(field.length <= 0){
        blnIsValid = false;
    }

    return blnIsValid;
}

<input type="button" id="btnSave" value="Save" onclick="return validate();" />
0

i have done this but the problem not solved

i have all the client side checks with the help of java script

when i click register button it show the message that first name is not filled and after that message it go on register.php page and enter the data into database (mySQL)

i say that if any message show in client side, the page should not go forward to register.php and don't save data into data base

waiting for your reply

0

Please show your code for the click event and the validation function. It sounds like you are still getting a postback which wouldn't be happening if you had return false for the click event.

0

On a side-note: i don't think depending on client-side checks is a good idea.
It's far too easy for hackers to misuse, so i would advise to develop a server-side check first.
Once that is working right, you can use javscript, so the user doesn't have to click a link to see what they did wrong

This question has already been answered. 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.