Click here to Skip to main content
15,665,319 members
Please Sign up or sign in to vote.
2.23/5 (3 votes)
See more:
I have a textbox and i want to prevent the user from entering characters which may cause harm to my database when i submit my form containing this textbox..
Can you help me plzz..
Thank u.. ..
Kornfeld Eliyahu Peter 19-Mar-14 4:04am    
Are you storing the data directly from JavaScript? Or there is a server side component for that?

That's the wrong idea. Any hacker who is beyond the knowledge of a script kiddie beginner will know how to submit the values using a script. And there he can enter anything he wants to do so. You have to secure your server, e.g. Parameterized Queries for the databse communication.
Share this answer
Member 10626057 19-Mar-14 14:11pm    
sql injection?
You can use Regular expression for that.Hence you have mentioned Javascript,please check below mentioned links for more info.

JavaScript RegExp Object

Regular Expressions

Regular Expressions with JavaScript
Share this answer
Use Regular Expression validation or use ajava Script validation

js val::
function fncheck()
        var pgng = document.getElementById("<%=txtPagingGoto.ClientID%>").value.trim();
        if(pgnd == "")
            alert('The textbox should not be empty...');
            return false;

call this fncheck in onclient click of button
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900