-3

I have a web page which has an input of integer. I find happy.js a lightweight form validation, so I want to try it.

4

1 回答 1

0

说,你有

<input id="integer" type="text" name="integer" />

你可以做

function is_integer(value) { return value.test(/^[+-]?[0-9]+$/) }

// Your "validation scheme", as per happyjs.com...
...
'#integer': {
  required: true,
  message: 'This must be an integer',
  test: is_integer // this can be *any* function that returns true or false
},
...

您是否尝试阅读http://happyjs.com/

于 2013-09-05T02:26:49.033 回答