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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Textbox Input Restricting

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hello,

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.

[C#]:

//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
doc.Form.Fields.Add(text);

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

Regards,
Pravin.

Theo
Replied On March 15, 2011 07:54 PM UTC

Hello,

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)) {
app.beep(0);
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:
F95305444178973.zip

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

Regards,
Geetha


CONFIRMATION

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.

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

;