1var regex = new RegExp("^[A-Za-z0-9? ,_-]+$");
2 var key = String.fromCharCode(event.charCode ? event.which : event.charCode);
3 if (!regex.test(key)) {
4 event.preventDefault();
5 return false;
6 }
7
1def isAlphaNumericStr(text):
2 if(re.match("^[A-Za-z0-9 -]+$", text) != None):
3 return True
4
5 root.bell()
6 return False
7
8 #TO ACTIVATE ON FIELD
9 txtCustomerName.configure(validate="key", validatecommand = (txtCustomerName.register(isAlphaNumericStr),'%P'))