DiegoP.
DiegoP.

Reputation: 45737

jQuery Validate no Hyphens

Hello I am using the jQuery Validation plugin to validate my HTML forms.

I have an input field that does not accept hyphens:

<label for="trackISRC"><span class="mandatory">*</span> Track ISRC:</label>
<input type="text" name="trackISRC" id="trackISRC" MAXLENGTH="12">

Now I have to find a way to make this field accept every type of character but NO hyphens using the jQuery validation plugin..

How can I do that?

This is an example of the jQuery validation plugin for rules:

$("#trackFile").rules("add", {
 accept: "mp3|WAV|MP3|wav"
});

Thanks!

Upvotes: 0

Views: 846

Answers (1)

Guard
Guard

Reputation: 6955

The regexp for no hyphens:

"^[^\\-]*$"

Upvotes: 2

Related Questions