Infopath: Restricting alphanumeric values in a text field - InfoPath Dev Sign in | Join | Help in Newbie Questions InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » Newbie Questions » Infopath: Restricting alphanumeric values in a text field Infopath: Restricting alphanumeric values in a text field Last post 11-10-2008 10:48 AM by sind2008. 4 replies. Page 1 of 1 (5 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 11-08-2008 09:54 AM sind2008 Joined on 11-08-2008 Posts 4 Infopath: Restricting alphanumeric values in a text field Reply Contact I am using Infopath 2003 SP2 to build a form. I need help on how to restrict only numbers on a data entry field. Like input mask in MS access. I am using Jscript to calculate totals using this field that time I am getting a runtime error if user enters a alphanumeric ( e.g. 40K) and asking Do you want to Debug? I don’t want this Run time error show, what I need to do? Thank you in advance for your help. Filed under: infopath 2003 11-08-2008 09:29 PM In reply to Jimmy Joined on 07-03-2008 Posts 2,595 Re: Infopath: Restricting alphanumeric values in a text field Mark as Not AnswerMark as Answer... Reply Contact You can check whether the number is a valid number and if it's not, skip the calculation and show the user an error. It would be easier to give you a more specific answer if you would show us the part of your code that is causing the error. Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 11-09-2008 07:36 AM In reply to sind2008 Joined on 11-08-2008 Posts 4 Re: Infopath: Restricting alphanumeric values in a text field Mark as Not AnswerMark as Answer... Reply Contact Jimmy, Thank you so much for your response. I want to allow only Numbers in a text field. The issue is if the users enters alphanumeric(e.g 100k), I will get a runtime error, due to the non-numeric value in a evaluate expression. I am using JScript to calculate a %. I don't want to allow user to enter alphanumeric values. Thanks Sind 11-09-2008 10:25 PM In reply to swathip Joined on 10-30-2007 India Posts 487 Re: Infopath: Restricting alphanumeric values in a text field Mark as Not AnswerMark as Answer... Reply Contact Hi Sind, You can change the data type of that field to integer. So that it can accept only integer values. Another way is adding a validation for the control by using custom patterns. The condition should be like ‘not(xdUtil:Match(string(.), "\d*"))’ . Swathipwww.ggktech.com 11-10-2008 10:48 AM In reply to sind2008 Joined on 11-08-2008 Posts 4 Re: Infopath: Restricting alphanumeric values in a text field Mark as Not AnswerMark as Answer... Reply Contact Thankyou very much for helping me!. This is the code worked for me. XDocument.Util.Match(xmlDom.selectSingleNode("//my:Ans210").text, "\\d*") Page 1 of 1 (5 items) Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
I am using Infopath 2003 SP2 to build a form. I need help on how to restrict only numbers on a data entry field. Like input mask in MS access. I am using Jscript to calculate totals using this field that time I am getting a runtime error if user enters a alphanumeric ( e.g. 40K) and asking Do you want to Debug? I don’t want this Run time error show, what I need to do? Thank you in advance for your help.
You can check whether the number is a valid number and if it's not, skip the calculation and show the user an error.
It would be easier to give you a more specific answer if you would show us the part of your code that is causing the error.
Jimmy,
Thank you so much for your response. I want to allow only Numbers in a text field. The issue is if the users enters alphanumeric(e.g 100k), I will get a runtime error, due to the non-numeric value in a evaluate expression. I am using JScript to calculate a %. I don't want to allow user to enter alphanumeric values.
Thanks
Sind
Hi Sind,
You can change the data type of that field to integer. So that it can accept only integer values. Another way is adding a validation for the control by using custom patterns. The condition should be like ‘not(xdUtil:Match(string(.), "\d*"))’ .
Thankyou very much for helping me!. This is the code worked for me.
XDocument.Util.Match(xmlDom.selectSingleNode("//my:Ans210").text, "\\d*")