how to validate the text field while submitting the form using jquery to display an alert message if the text field contains other than keyboard special characters like ascii characters form 127-255 and iso-8859-1 caharacters
Sample Code :
Javascript Code :
<script type="text/javascript">
$(function()
{
$('#send').click(function()
{
var firstname=$('#firstname').val();
var pattern = "^[a-zA-Z0-9~`!@#$%^&*()_+-={}|:;<>,.?\/']+$";
if((!firstname.match(pattern)))
{
alert('your input contained not supported characters');
return false;
}
return true;
});
});
</script>
Html Code :
<form id="ajax_form" action="ajaxoutput.php">
<input type="text" name="FirstName" id="firstname" placeholder="FirstName" /><br>
<input type="text" name="LastName" placeholder="LastName" /><br>
<input type="file" name="image"/><br/>
<input type="submit" value="submit" name="submit" id="send" /> <input type="reset" value="reset"/>
</form>
áěěíóúůýčď�?řšťž
.