This is very simple javascript code.it is used to check if string contains special characters or not.
Step 1: Need library file to perform empty action.Please copy and Paste below library file.
Please share your comments and feedback.Thanks.Please subscribe my updates via email.
Step 1: Need library file to perform empty action.Please copy and Paste below library file.
jQuery Function
<script type="text/javascript">
$(function () {
$('#btncheck').click(function () {
var txt = $('#txtValue').val(); //Entered Value
if (/^[a-zA-Z0-9- ]*$/.test(txt) == false) {
alert('Your String Contains illegal Characters');
}
else
{
alert('Your String Not Contains illegal Characters');
}
})
})
</script>
$(function () {
$('#btncheck').click(function () {
var txt = $('#txtValue').val(); //Entered Value
if (/^[a-zA-Z0-9- ]*$/.test(txt) == false) {
alert('Your String Contains illegal Characters');
}
else
{
alert('Your String Not Contains illegal Characters');
}
})
})
</script>
HTML
Enter Your Text:
<input type="text" id="txtValue" />
<input type="button" id="btncheck" value="Check" />
<input type="text" id="txtValue" />
<input type="button" id="btncheck" value="Check" />
No comments:
Post a Comment