1

I have an input element of the type text that I wish to allow only input that has a . between every other character. I'm a bit obsessive about data integrity and wish to build in as many failsaves as I can, starting with the users.

The form is set up to receive input like this:

Firstname:     |John____________________|
First Letters: |J.W.H.__________________|
Lastname:      |Baker___________________|

I have the following regexp that works beautifully normally, but won't work in the pattern field of the form.

/.{1}\./g

This is the form that I am using to match against, but it won't let me pass if I fill in the correct pattern.

<input type="text" name="firstletters" pattern="/.{1}\./g" title="First name letters with a . in between each letter.">

Anyone have a solution? The length of the string can vary depending how many first names the person being added to the database.

4

1 に答える 1

2

^(文字列の開始)、$(文字列の終了) でグループを使用する必要があります。

^(.\.)+$
于 2013-01-16T16:10:44.883 に答える