phoneNumber Validation

Hi guys, have a good days.

May I know that Ignition able to do the validation checking for phone number format which the users only able to insert number instead of alphabetic characters ?

Vision or Perspective? Vision has the Formatted Text Field component which accepts a regex to limit input text. I don’t think there’s one yet for a Perspective

Hi Bro nminchin, what I’m taking is for Perspective.

I see. So what can I do for Perspective for phoneNumber validation which accept only number instead of alphabetic characters ?

Thanks in advance.

Nothing at the moment I don’t believe

What if I use python phone number validation regex in Ignition. It is possible ?

Of course,but you’ll have to post-process the value set by the user

May I know where is the best place to write the regex scripts ? Either Configure Events or Configure Scripts ?

I used a text field to enter phone numbers. I used a change script, right click on text property add change script.

This is my script, it’s not the best and could probably be better, but did what I wanted:

import phonenumbers
import re

x = currentValue.value
regex = "^\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}$"
	
if re.search(regex,x):
	z = phonenumbers.parse(x, "IN")
	if phonenumbers.is_valid_number(z):
		x = phonenumbers.format_number(phonenumbers.parse(self.props.text, 'US'), phonenumbers.PhoneNumberFormat.NATIONAL)
		self.props.text = x
		self.custom.OK = 1
	else:
		self.custom.OK = 0
else:
	self.custom.OK = 0

Format is (222) 333-3456. You will need to import phononumbers, I think I got it here:

You will need to do your homework to make this work. I can’t help much more than what I wrote up in this post.

Edit, it should be noted, I don’t prevent characters, I only make sure what was entered is correct, hence the custom property “OK”.

Problem Solved. Thanks Brother