xxxxxxxxxx
<input type="text" name="country_code" pattern="[0-9]+" title="please enter number only" required="required">
xxxxxxxxxx
import re
def contains_only_numbers(input_string):
pattern = r'^\d+$'
return bool(re.match(pattern, input_string))
# Test the function
inputs = ['123', 'abc123', '123$%']
for input_str in inputs:
print(f"{input_str}: {contains_only_numbers(input_str)}")