Validate Data Entry Has Numbers and Letters Both

[Total: 0    Average: 0/5]

This shows how to ensure that both letters and numbers are used in the text box.

Body Code:

<input type=text name=t1>
<input type=button value="validate" onclick=doIt(this.form)>
function doIt(form)
  var SHOW_ALERT = true; // make be false to supress the alerts.
  var _alpha =[a-z]|[A-Z]/);
  var _numer =;
  if (_alpha==-1)
    if (SHOW_ALERT) alert("No characters!n"+_alpha);
	return false;
  if (_numer==-1)
    if (SHOW_ALERT) alert("No numbers!n"+_numer);
	return false;
  if (SHOW_ALERT) alert("Data Validated!");
  return true;

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *