We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Textbox Input Restricting

Thread ID:





95305 Jun 30,2010 08:34 PM UTC Mar 16,2011 05:59 AM UTC ASP.NET Web Forms (Classic) 3
Tags: PDF
Asked On June 30, 2010 08:34 PM UTC


I want to limit what can be typed into a textbox. Specifically to only allow numbers. and maybe even a maximum/minimum number size. Would this done with a regex? Or which function is used to do this.

Thank you.

Pravin Joshua D [Syncfusion]
Replied On July 5, 2010 10:05 AM UTC

Hi Theo,

Thank you for using Essential PDF.

Form field validation can be done using PdfJavascriptAction. Please add the required PdfJavaScript in the validate event of the form field. This javascript will be executed whenever the value has been entered to the field. Please have a look at the sample code snippet below to add javascript in the form field validate event.


//Define the form field
PdfTextBoxField text = new PdfTextBoxField(page,"Text1");

// Add validation javascript
text.Actions.Validate = new PdfJavaScriptAction("app.alert(\"You are looking at Java script action of PDF \")");

// Define the field bounds and properties
text.Bounds = new RectangleF(100,100,100,100);
text.BorderColor = new PdfColor(Color.Red);

//Add the form field to the document

Please try this and let us know if you have any questions.


Replied On March 15, 2011 07:54 PM UTC


I am having issues with the actual javascript. I want to restrict the input to only allow numbers in the textbox.

The error I am getting is "Input string was not in a correct format".

The javascript im using is directly from the adobe guide here. Page 84. "http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_developer_guide.pdf"

Any suggestions? Is the javascript handled differently in Syncfusion?

if ( event.willCommit ) {
var value = ""+event.value.replace(/\s*/g,"");
if ( value != "" ) {
if (!isFinite(value)) {
event.rc = false;
} else if ( event.change == " " ) {
event.change = "";

Geetha M [Syncfusion]
Replied On March 16, 2011 05:59 AM UTC

Hi Theo,

Thank you for your interest in Syncfusion products.

I am afraid that I am not able to reproduce the exception. I am able to insert a JavaScript Action to 'Validate' and I have placed my test sample in the following link:

Could you please try running the above sample and let me know about it?



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon