---
title: "webView(_:shouldInsertText:replacing:given:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/webeditingdelegate/webview(_:shouldinserttext:replacing:given:)"
---

# webView(_:shouldInsertText:replacing:given:)

Returns whether a user should be allowed to insert text in place of a range of content.

## Declaration

```swift
optional func webView(_ webView: WebView!, shouldInsertText text: String!, replacing range: DOMRange!, given action: WebViewInsertAction) -> Bool
```

## Parameters

- `webView`: The web view that the user is editing.
- `text`: The text to insert.
- `range`: The portion of the document that will be replaced with text.
- `action`: Indicates the type of user action that initiated the insertion.

## Return Value

Return Value true if the user should be allowed to insert text in webView; otherwise, false.

## Discussion

Discussion This method may perform an alternate action—for example, insert different text—and return false.

## See Also

### Related Documentation

- [webViewDidChange(_:)](webkit/webeditingdelegate/webviewdidchange(_:).md)
- [webView(_:shouldInsert:replacing:given:)](webkit/webeditingdelegate/webview(_:shouldinsert:replacing:given:).md)
