我有一个表admin_config,它是这样的:-
在Laravel中构建表单时,我这样做是:-
From<Vec<T>>
HTML表单如下:-
我需要表单的jquery表单验证。当前的表单验证如下:-
use std::convert::AsRef;
enum Value
{
Int(i64),
Flt(f64),
}
fn main() {
use Value::*;
let x = Box::new(vec![Int(5),Flt(22.5),Int(22)]);
foo(*x)
}
fn foo<S>(slice: S) where S: AsRef<[Value]> {
}
我想检查额外的验证,例如输入类型是否为url,那么它将具有特殊的url验证规则和消息。
我该怎么做?
编辑:
答案 0 :(得分:0)
您好,请尝试执行此操作,希望这可以解决您的网址验证问题
$( "#myform" ).validate( {
// This global normalizer will trim the value of all elements
// before validatng them.
normalizer: function( value ) {
return $.trim( value );
},
rules: {
username: {
required: true
},
url_input: {
required: true,
url: true,
// We don't need to trim the value of this element, so we overrided
// the global normalizer in order to append 'http://' to the url value
// if doesn't already.
normalizer: function( value ) {
var url = value;
// Check if it doesn't start with http:// or https:// or ftp://
if ( url && url.substr( 0, 7 ) !== "http://"
&& url.substr( 0, 8 ) !== "https://"
&& url.substr( 0, 6 ) !== "ftp://" ) {
// then prefix with http://
url = "http://" + url;
}
// Return the new url
return url;
}
}
}
} );
或者您也可以使用
$( "#myform" ).validate({
rules: {
field: {
required: true,
url: true
}
}
});