Posted by a ceTe Software moderator
There is document level JavaScript in v4, but form field level JavaScript was introduced in v9. With v9 or greater, you can use the following code to accomplish this:
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
TextField textField = new TextField("txt", 50, 75, 150, 100); ;
textField.DefaultValue = "0";
textField.ToolTip = "Enter only Numbers";
textField.ReaderEvents.OnBlur = new JavaScriptAction(" var no = this.getField(\"txt\").value; if( isNaN(no)) { app.alert(\"Please Enter number in the text field\"); } ");
page.Elements.Add(textField);
document.Draw(@"c:\temp\output.pdf");
Thanks,
ceTe Software Support Team