Alpha Numeric And Few Special Character Allowed Validation

Wednesday, August 3, 2011

Hello Friends,

jQuery provides you alphanumeric validation or only Special Character validation, below code will help you validate your textbox with alphanumeric and also allow few special character, you can see regex pattern below, you can add your special character which you want to can also see live demo by entering your text in below textbox.. 


Enter Name :

Note : Few character allowed (!,\-,.,&,*,#,@,/)

<title>jQuery test page</title>
<script src="" type="text/javascript"></script>

<script type="text/javascript">
function loadContent() {

            document.getElementById('error').innerHTML="Validate Success.";
            document.getElementById("error").setAttribute("style", "color:Green;"); 
            document.getElementById('error').innerHTML="Not Validate, its wrong.";
            document.getElementById("error").setAttribute("style", "color:Red;"); 

function validate()
    return /^([a-zA-Z 0-9]([a-zA-Z 0-9\s\[\]\!\(\)\-\.\&\*\#\@/\\(/)/)])+$)/.test(document.getElementById('txtcheck').value);
Enter Name : <input type="text" id="txtcheck" onblur="loadContent()" />
<span id="error"></span><br />
Note : Few character allowed (!,\-,.,&,*,#,@,/)

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer
e-Procurement Technologies Ltd (India)

1 comment :

Anonymous said...

hello, what's new, what's up?