Use this file to discover all available pages before exploring further.
Form validation is critical for data integrity and user experience. This recipe demonstrates how to use bdg to test all form fields with edge cases and identify validation gaps.
Navigate to the form and use the form discovery command to see all fields.
bdg https://testpages.eviltester.com/styled/validation/input-validation.html# Discover all form fields with current statebdg dom form
Expected output:
FORMS DISCOVERED: 1══════════════════════════════════════════════════════════════Form: "Input Validation Test"────────────────────────────────────────────────────────────── # Type Label Value Status────────────────────────────────────────────────────────────── 0 text First Name* empty required 1 email Email Address* empty required 2 number Age empty ok 3 password Password* empty required 4 checkbox Accept Terms* unchecked required────────────────────────────────────────────────────────────── 5 button Submit (primary) enabled══════════════════════════════════════════════════════════════Summary: 0/5 fields filled | 4 required remaining | NOT readyRemaining: bdg dom fill 0 "<value>" # First Name bdg dom fill 1 "<value>" # Email Address bdg dom fill 3 "<value>" # Password bdg dom click 4 # Accept Terms
The form discovery shows field indices, types, validation state, and ready-to-use commands.
2
Test required field validation
Attempt to submit the form without filling required fields.
# Try clicking submit with empty required fieldsbdg dom click 5# Check for validation messages in DOMbdg dom query ".error-message"bdg dom query "[aria-invalid='true']"# Check console for validation errorsbdg console
Systematically test boundary conditions and invalid formats.
# Test email with invalid formatsbdg dom fill 1 "not-an-email"bdg dom click 5bdg dom query "#email-error" --json | jq -r '.data.nodes[0].text'bdg dom fill 1 "missing-at-sign.com"bdg dom click 5bdg dom fill 1 "no-domain@"bdg dom click 5# Test age field with out-of-range valuesbdg dom fill 2 "-5" # Negative numberbdg dom fill 2 "999" # Too largebdg dom fill 2 "abc" # Non-numeric# Test password with weak inputsbdg dom fill 3 "123" # Too shortbdg dom fill 3 "password" # Too common
After each invalid input, check for error messages:
# Test minimum length (assuming first name requires 2+ chars)bdg dom fill 0 "A"bdg dom click 5bdg dom eval 'document.querySelector("[name=firstName]").validationMessage'# Test maximum length (if field has maxlength)bdg dom eval 'document.querySelector("[name=firstName]").maxLength'# Fill with string exceeding max lengthbdg dom fill 0 "$(printf 'A%.0s' {1..100})"bdg dom eval 'document.querySelector("[name=firstName]").value.length'
Expected output:
{ "result": { "type": "number", "value": 50 }}
The browser enforced the maxlength attribute by truncating at 50 characters.
5
Test with valid inputs
Fill all fields with valid data and verify the form accepts submission.
# Fill all required fields with valid databdg dom fill 0 "John Doe"bdg dom fill 1 "john.doe@example.com"bdg dom fill 2 "25"bdg dom fill 3 "SecurePass123!"bdg dom click 4 # Accept terms checkbox# Verify form state shows ready to submitbdg dom form --json | jq '.data.forms[0].summary.readyToSubmit'# Submit formbdg dom click 5# Check for success message or navigationbdg peek --consolebdg dom query ".success-message"
Expected output:
true
6
Test edge cases
Test special characters, unicode, and boundary values.
# Test special characters in text fieldsbdg dom fill 0 "O'Brien" # Apostrophebdg dom fill 0 "José García" # Accented charactersbdg dom fill 0 "<script>alert('xss')</script>" # XSS attempt# Test email edge casesbdg dom fill 1 "user+tag@example.com" # Plus addressingbdg dom fill 1 "user@subdomain.example.com" # Subdomainbdg dom fill 1 "user@localhost" # Localhost (often invalid)# Test numeric boundariesbdg dom fill 2 "0" # Minimumbdg dom fill 2 "150" # Maximum (if age field)bdg dom fill 2 "18" # Common threshold# After each, check validationbdg dom eval 'document.querySelector("[name=firstName]").validity.valid'
7
Monitor network requests during submission
Watch for AJAX validation or form submission requests.
# Submit form and watch networkbdg dom click 5# Check for POST requestsbdg network list --filter "method:POST" --last 5# Inspect responsebdg network list --json | jq '.data.requests[] | select(.method == "POST") | {url, status, responseBody}'
Symptom: Form submits even with invalid data.Test:
# Disable HTML5 validation and try to submitbdg dom eval 'document.querySelector("form").setAttribute("novalidate", "true")'bdg dom click 5bdg network list --filter "method:POST"
If the POST request succeeds with invalid data, server-side validation is missing.
Validation messages not accessible
Symptom: Error messages visible but not announced to screen readers.Test:
# Check for aria-describedby linking error messagesbdg dom query "[aria-invalid='true']" --json | jq '.data.nodes[] | .attributes["aria-describedby"]'# Verify error messages have role="alert"bdg dom query ".error-message" --json | jq '.data.nodes[] | .attributes.role'
Inconsistent validation triggers
Symptom: Validation only runs on submit, not on blur.Test:
# Fill field with invalid data and tab awaybdg dom fill 1 "invalid-email"bdg dom pressKey 1 Tab# Check if error message appearedbdg dom query "#email-error"
Best practice: Validate on blur for immediate feedback.
XSS vulnerabilities in error messages
Symptom: User input reflected in error messages without sanitization.Test:
bdg dom fill 0 "<img src=x onerror='alert(1)'>"bdg dom click 5# Check if script tags are in DOMbdg dom query "script" --json | jq '.data.nodes | length'# Check error message renderingbdg dom get ".error-message" --raw