# Custom form - Validate input to include only Hebrew and a handful of special characters

**URL:** <https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289>\
**Category:** Ask for Help\
**Created:** [December 23, 2021, 4:49pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289 "2021-12-23T16:49:34Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Test\_Test](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/test_test/32/30930_2.png) [@Test\_Test](https://community.glideapps.com/u/Test_Test)\
**Post date:** [December 23, 2021, 4:49pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/1 "2021-12-23T16:49:34Z")

</div>

Hi all,  
Using a [custom form](https://community.glideapps.com/t/how-do-i-create-a-custom-form/25014) with a dedicated work table. RegEx is working great to validate anything numeric but I’m stuck when it comes to Hebrew characters and a handful of special characters (such as ’ (single quote), -(hyphen), space, etc.).  
In a nutshell, I’d like to add a column that’ll validate input of a text field. Column should return “false” if contains **anything other than** Hebrew and these special characters.

I found [this great idea](https://stackoverflow.com/a/23626073/13708028) on StackOverflow which is actually using JavaScript to validate the RegEx.

```auto
function is_heb(Field) {
        // First choose the required validation

        HebrewChars = new RegExp("^[\u0590-\u05FF]+$");
        AlphaNumericChars = new RegExp("^[a-zA-Z0-9\-]+$");
        EnglishChars = new RegExp("^[a-zA-Z\-]+$");
        LegalChars = new RegExp("^[a-zA-Z\-\u0590-\u05FF]+$"); //Note that this one allows space 

        // Then use it

        if (!LegalChars.test(Field)) {
            return false;
        } else
            return true;
    }

```

Here it is, “adapted” for Glide and for my specific use case:

```auto
{

        HebrewChars = new RegExp("^[\u0590-\u05FF]+$");
        
           LegalChars = new RegExp("^[a-zA-Z\-\u0590-\u05FF]+$"); //Note that this one allows space 

      if (!LegalChars.test(p1)) {
            return false;
        } else
            return true;
    }

```

I was sure it worked, but then…it didn’t 🙂  
I fear I might have “touched” something to mess it up, but cannot find it. Of course I tried to build it again from scratch but still no luck.  
Any ideas?  
Thanks

---

<div class="post-metadata">

**Author:** ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)\
**Post date:** [December 23, 2021, 7:01pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/2 "2021-12-23T19:01:22Z")

</div>

Are you using Glide sheets or google sheets?

---

<div class="post-metadata">

**Author:** ![Test\_Test](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/test_test/32/30930_2.png) [@Test\_Test](https://community.glideapps.com/u/Test_Test)\
**Post date:** [December 23, 2021, 7:14pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/3 "2021-12-23T19:14:18Z")

</div>

For this form-specific rewritable situation I’m using a Glide Sheet. Is that not recommended?

---

<div class="post-metadata">

**Author:** ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)\
**Post date:** [December 23, 2021, 7:21pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/4 "2021-12-23T19:21:44Z")

</div>

No it’s not that. I was just asking to see what flexibility you had within the app.

---

<div class="post-metadata">

**Author:** ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)\
**Post date:** [December 23, 2021, 7:26pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/5 "2021-12-23T19:26:45Z")

</div>

> [@Test\_Test](#):
>
> ```auto
> {
> 
> HebrewChars = new RegExp("^[\u0590-\u05FF]+$");
>         
> LegalChars = new RegExp("^[a-zA-Z\-\u0590-\u05FF]+$"); //Note that this one allows space 
> 
> if (!LegalChars.test(p1)) {
> return false;
> } else
> return true;
> }
> 
> ```

So I entered your formula into a new column with javascript code and used p1 as my addressing another column and it worked fine for me.

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/7/4/742be25700ffb2cbc3ff401e18780c6779c43b15.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/8/a881a4fa73cfa116962526af10d783ff648d6593.png)

---

<div class="post-metadata">

**Author:** ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)\
**Post date:** [December 23, 2021, 7:49pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/6 "2021-12-23T19:49:31Z")

</div>

After looking into this further your javascript works fine outside of glide and in my example it identified a period “.” as non hebrew which made me think it was 100% working. I attempted to use it even further and any information placed in the field in any other language with out a period “.” is recognized as true as well.

I do not think that the javascript portion of Glide has matured enough to work in this manner. I will keep working on it but your code in either format listed above works the way it should outside of Glide.

---

<div class="post-metadata">

**Author:** ![Test\_Test](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/test_test/32/30930_2.png) [@Test\_Test](https://community.glideapps.com/u/Test_Test)\
**Post date:** [December 23, 2021, 8:09pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/7 "2021-12-23T20:09:39Z")

</div>

Thanks for assisting.  
I actually think the code part inside Java is working rather well.  
Here’s another code I picked up. this time to check integrity of an Israeli ID number. I have not played with it extensively, but on the surface it does seem to function properly. Happy to hear your input.

```auto
{
	p1 = String(p1).trim();
	if (p1.length > 9 || isNaN(p1)) return false;
	p1 = p1.length < 9 ? ("00000000" + p1).slice(-9) : p1;
		return Array.from(p1, Number).reduce((counter, digit, i) => {
			const step = digit * ((i % 2) + 1);
			return counter + (step > 9 ? step - 9 : step);
		}) % 10 === 0;
}

```

---

<div class="post-metadata">

**Author:** ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)\
**Post date:** [December 23, 2021, 8:26pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/9 "2021-12-23T20:26:39Z")

</div>

Ok, this works. Using English characters and manually removing the space using javascript will give you the correct “true” value.

```auto
{

        HebrewChars = new RegExp("^[\u0590-\u05FF]+$");
        
           EnglishChars = new RegExp("^[a-zA-Z\-]+$");

var text1 = p1;
var text2 = text1.split(" ").join("");

      if (!EnglishChars.test(text2)) {
            return true;
        } else
            return false;
    }

```

---

<div class="post-metadata">

**Author:** ![Test\_Test](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/test_test/32/30930_2.png) [@Test\_Test](https://community.glideapps.com/u/Test_Test)\
**Post date:** [December 23, 2021, 9:32pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/10 "2021-12-23T21:32:46Z")

</div>

This looks great but please help be “decode” this code. Does it just check if p1 doesn’t have English characters?  
The idea to have a “clean” input, i.e. just Hebrew characters and select special characters.

---

<div class="post-metadata">

**Author:** ![Test\_Test](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/test_test/32/30930_2.png) [@Test\_Test](https://community.glideapps.com/u/Test_Test)\
**Post date:** [December 23, 2021, 10:07pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/12 "2021-12-23T22:07:45Z")

</div>

> [@Drearystate](#):
>
> ````auto
> > {
> 
> HebrewChars = new RegExp("^[\u0590-\u05FF]+$");
>         
> EnglishChars = new RegExp("^[a-zA-Z\-]+$");
> 
> var text1 = p1;
> var text2 = text1.split(" ").join("");
> 
> if (!EnglishChars.test(text2)) {
> return true;
> } else
> return false;
> }
> > ```
> 
> ````

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/9/5941ffddd0c78b2a1855638f0774031503f18741.png)

Sorry, but this doesn’t work ☹  
Once you enter a digit, it either return false, returns true when shouldn’t or return nothing at all.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/6/668fb577677b7b1676206092483ef89dbee4ee9c.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/7/0/70d3db23231c71270448695abc6d63e28d7e3235.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/9/298f2a87e464d4b14144043e4fa0447a5d273bdb.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/d/2d9d828459a120a3f7deec91553fe5aca8e74236.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/f/effce19adcaf075877487ff1671862cbd4173b6c.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/9/6917bd350621c8a020f441a42005deec97c6b0d7.png)

~~Any~~~~ other ~~~~ideas~~~~?~~  
~~Thanks~~~~ again ~~~~for~~~~ assisting~~(

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [December 23, 2021, 10:38pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/13 "2021-12-23T22:38:53Z")

</div>

Hola @Test_Test

Does it work for you?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/b/9bea48ec55f8185c20a26285e8a96346f7e98d91.png)

This is the JS code I’m using but don’t know if something is still missing 😇

```auto
const HebrewChars = /^[\u0590-\u05FF]+$/;

if (!HebrewChars.test(p1)) 
    return false
else
    return true

```

Let me know if this helps you.

Feliz día!

---

<div class="post-metadata">

**Author:** ![Test\_Test](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/test_test/32/30930_2.png) [@Test\_Test](https://community.glideapps.com/u/Test_Test)\
**Post date:** [December 24, 2021, 7:35am UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/14 "2021-12-24T07:35:04Z")

</div>

> [@gvalero](#):
>
> ```auto
> onst HebrewChars = /^[\u0590-\u05FF]+$/;
> 
> if (!HebrewChars.test(p1)) 
> return false
> else
> return true
> 
> ```

Hola @gvalero,  
Gracias!  
This is indeed working for Hebrew, but it doesn’t allow the special characters I mentioned (apart from “space” which is working):  
– מקף  
’ גרש

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [December 24, 2021, 2:10pm UTC](https://community.glideapps.com/t/custom-form-validate-input-to-include-only-hebrew-and-a-handful-of-special-characters/36289/15 "2021-12-24T14:10:50Z")

</div>

Hola @Test_Test

I thought in another way (inverse logic 🙃) and I think it works now: only Hebrew characters **and** special characters **and not** numbers!

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/b/8b46356693f5871b3fa624d296e85b9954697b33.png)

Happy Christmas/Feliz Navidad!
