This javascript will help you to accept only strings and numbers and donot accept special characters.It checks alphanumeric characters.
Features
a) By using this javascript, the textbox accepts only strings and numbers but not the special characters. It checks for alpha numeric characters alone.
b) Just copy the code into your page and use it.
Preview
Code
Javascript
<!-- Script by hscripts.com -->
<!-- Copyright of HIOX INDIA -->
<!-- More scripts @ http://www.hscripts.com -->
<script type="text/javascript">
var r={'special':/[\W]/g}
function valid(o,w)
{
o.value = o.value.replace(r[w],'');
}
</script>
<!-- Script by hscripts.com -->
For customization of this script or any script development, contact us at support@hscripts.com
Usage
a) This script is used to accept only strings and numbers and do not accept special characters.
b) The function valid() is called for validation that is the typing character is a special character means remove that characters because this text box doesn't accept special characters.
c) Copy the code into your page and use it.
License
- The javascript (misspelled as java script) is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Click Here for detailed license information.
- You can purchase the script if your requirements does not meet our GPL License terms.