ByteScout PDF SDK - VB.NET - External JS for form data validation - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout PDF SDK – VB.NET – External JS for form data validation

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – VB.NET – External JS for form data validation

external JS for form data validation in VB.NET using ByteScout PDF SDK

ByteScout PDF SDK is the library for pdf documents generation, modification and updates. Can also generate and fill PDF forms. Provides support for text (fonts, style, size, font family), layers, pdf form fields, vector and raster drawings.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

ExternalJsFormValidation.vbproj
      
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{951C634C-4684-40A5-919C-741C5CA61EA4}</ProjectGuid> <OutputType>Exe</OutputType> <StartupObject>Sub Main</StartupObject> <RootNamespace>ExternalJsFormValidation</RootNamespace> <AssemblyName>ExternalJsFormValidation</AssemblyName> <FileAlignment>512</FileAlignment> <MyType>Console</MyType> <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <DefineDebug>true</DefineDebug> <DefineTrace>true</DefineTrace> <OutputPath>bin\Debug\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugType>pdbonly</DebugType> <DefineDebug>false</DefineDebug> <DefineTrace>true</DefineTrace> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> </PropertyGroup> <PropertyGroup> <OptionExplicit>On</OptionExplicit> </PropertyGroup> <PropertyGroup> <OptionCompare>Binary</OptionCompare> </PropertyGroup> <PropertyGroup> <OptionStrict>Off</OptionStrict> </PropertyGroup> <PropertyGroup> <OptionInfer>On</OptionInfer> </PropertyGroup> <ItemGroup> <Reference Include="Bytescout.PDF, Version=1.0.0.15, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> </ItemGroup> <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> <Import Include="System.Collections" /> <Import Include="System.Collections.Generic" /> <Import Include="System.Data" /> <Import Include="System.Diagnostics" /> </ItemGroup> <ItemGroup> <Compile Include="Program.vb" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Program.vb
      
Imports Bytescout.PDF ''' <summary> ''' This example demonstrates validation of form with JavaScript ''' </summary> Class Program Shared Sub Main() ' Create new document Dim pdfDocument = New Document() pdfDocument.RegistrationName = "demo" pdfDocument.RegistrationKey = "demo" ' Add page Dim page As New Page(PaperFormat.A4) pdfDocument.Pages.Add(page) ' Get page canvas Dim canvas As Canvas = page.Canvas ' Prepare font and brush Dim font As Font = New Font(StandardFonts.Helvetica, 15) Dim blackBrush As New SolidBrush() ' Draw First Name Label canvas.DrawString("First Name: ", font, blackBrush, 50, 50) ' Create FirstName EditBox Dim firstName As EditBox = New EditBox(130, 50, 100, 30, "FirstName") ' Add javascript validation on focus lose firstName.OnLoseFocus = New JavaScriptAction(" if(event.value == ''){ app.alert('First Name is required!'); } ") ' Add First Name EditBox to page page.Annotations.Add(firstName) ' Draw Last Name Label canvas.DrawString("Last Name: ", font, blackBrush, 50, 100) ' Create Last Name EditBox Dim lastName As EditBox = New EditBox(130, 100, 100, 30, "LastName") ' Add javascript validation on focus lose lastName.OnLoseFocus = New JavaScriptAction(" if(event.value == ''){ app.alert('Last Name is required!'); } ") page.Annotations.Add(lastName) ' Create a button Dim btnSubmit As PushButton = New PushButton(50, 150, 150, 30, "SayHello") btnSubmit.Caption = "Say Hello!" ' Javascript action to validate as well as displaying message btnSubmit.OnMouseDown = New JavaScriptAction(" var valFirstName = this.getField('FirstName').value; var valLastName = this.getField('LastName').value; if(valFirstName == '' || valLastName == ''){ app.alert('Please complete incompete values in form!'); } else{ var messageToDisplay = 'Hello, ' + valLastName + ' ' + valFirstName + '!'; app.alert(messageToDisplay, 4); } ") page.Annotations.Add(btnSubmit) ' Save document to file pdfDocument.Save("result.pdf") ' Cleanup pdfDocument.Dispose() ' Open document in default PDF viewer app Process.Start("result.pdf") End Sub End Class

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Explore Samples

Sign Up for ByteScout PDF SDK Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next