Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: add url field type validation

Marc Seitz16bd8bb19f8f
diff --git a/components/view/access-form/custom-fields-section.tsx b/components/view/access-form/custom-fields-section.tsx
index 89812a91..9cd9bd72 100644
--- a/components/view/access-form/custom-fields-section.tsx
+++ b/components/view/access-form/custom-fields-section.tsx
@@ -49,8 +49,24 @@ export default function CustomFieldsSection({
<InputComponent
name={field.identifier || ""}
id={field.id || ""}
- type={field.type === "NUMBER" ? "number" : "text"}
+ type={
+ field.type === "NUMBER"
+ ? "number"
+ : field.type === "URL"
+ ? "url"
+ : "text"
+ }
+ pattern={field.type === "URL" ? "https://.*" : undefined}
+ onInvalid={(e) => {
+ if (field.type === "URL") {
+ e.currentTarget.setCustomValidity(
+ "Please enter a valid URL starting with https://",
+ );
+ }
+ }}
+ onInput={(e) => e.currentTarget.setCustomValidity("")}
autoComplete="off"
+ data-1p-ignore
required={field.required}
disabled={field.disabled}
className={cn(