<p>You can use the library you've linked.</p>

<p>Instead of using:</p>

<pre><code>isValid(address, 0)
</code></pre>

<p>use</p>

<pre><code>isValid(address, 5)
</code></pre>

CC BY-SA 3.0
2014-12-14T21:17:33.527Z
2014-12-14T21:24:49.553Z
2014-12-14T21:24:49.553Z
Nick ODell
<p>I looked at <a href="http://cryptocoinjs.com/modules/currency/coinstring/" rel="nofollow">coinstring.js</a> but it looks like it only validates simple BTC addresses (<code>1</code>-prepended addresses).</p>

<blockquote>
  <h3>isValid(base58str, version)</h3>
  
  <p>Validates whether the address string or wallet import format string is valid.</p>
  
  <p><code>base58str</code>: A <code>string</code> that is either the wallet import format or public address.</p>
  
  <p><code>version</code>: Is an integer representing the version or <code>Buffer</code>. See below for more information.</p>
  
  <p>Returns a <code>true</code> or <code>false</code>.</p>
</blockquote>

<p>I'm looking for a JS library that can validate BIP16 <a href="https://en.bitcoin.it/wiki/Pay_to_script_hash" rel="nofollow">P2SH</a> addresses.</p>

<multi-signature><p2sh>
Is there a JavaScript library for validating P2SH addresses?
kyledcline
# Is there a JavaScript library for validating P2SH addresses?

(Asked by: username_0 on 2014-12-14)

I looked at [coinstring.js](http://cryptocoinjs.com/modules/currency/coinstring/) but it looks like it only validates simple BTC addresses (`1`-prepended addresses).

> ### isValid(base58str, version)
>
> Validates whether the address string or wallet import format string is valid.
>
> `base58str`: A `string` that is either the wallet import format or public address.
>
> `version`: Is an integer representing the version or `Buffer`. See below for more information.
>
> Returns a `true` or `false`.

I'm looking for a JS library that can validate BIP16 [P2SH](https://en.bitcoin.it/wiki/Pay_to_script_hash) addresses.

**Tags:** multi-signature, p2sh


---

## 1 answers

### Answer by username_1 on 2014-12-14. Score: 1 | Accepted answer

You can use the library you've linked.
Instead of using:
isValid(address, 0)

use
isValid(address, 5)


---

