using the jquery validation plugin, how can I add a regex validation on a textbox?

后端 未结 2 1187
一向
一向 2020-12-05 11:34

I am using the jquery validation plugin from: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

How can I add a regex check on a particular textbox?

2条回答
  •  忘掉有多难
    2020-12-05 11:50

    Not familiar with jQuery validation plugin, but something like this should do the trick:

    var alNumRegex = /^([a-zA-Z0-9]+)$/; //only letters and numbers
    if(alNumRegex.test($('#myTextbox').val())) {
        alert("value of myTextbox is an alphanumeric string");
    }
    

提交回复
热议问题