wldragon / smvalidator Goto Github PK
View Code? Open in Web Editor NEWa simple but powerful tool for validating form fields. support bootstrap and your own styles.
Home Page: https://github.com/WLDragon/SMValidator
License: MIT License
a simple but powerful tool for validating form fields. support bootstrap and your own styles.
Home Page: https://github.com/WLDragon/SMValidator
License: MIT License
SMValidator.setSkin('bootstrap');
(function($view) {
/* ================================== Configs ================================== */
var options = {
login: {
/* account: $.view("input[name='account']"),
password: $.view("input[name='password']"),*/
},
};
/* ================================== Triggers ================================== */
$view
.on("click" , "#submitLogin" , submibtLogin )
/* ================================== Functions ================================== */
var validator = new SMValidator('form', {
fields: {
short: true,
account: {
rule: [/^[a-zA-z][a-zA-Z0-9_]{2,9}$/i, '请输入正确的账号'],
required: '请输入登录账号',
failCss: 'error',
failStyle: {color:'#c3f', border:'1px solid #f00'},
passCss: 'success',
passStyle: {color: '#090'},
failHtml: ["*.help-inline"],
},
password: {
rule: [/^[a-zA-z][a-zA-Z0-9_]{2,9}$/i, '请输入正确的密码'],
required: '请输入密码',
failCss: 'error',
failStyle: {color:'#c3f', border:'1px solid #f00'},
passCss: 'success',
passStyle: {color: '#090'},
failHtml: ["*.help-block"],
},
},
});
function submibtLogin()
{
console.log(validator);
}
})($(document.body));
function modal_sub(){ asyncAccountName(); if(SMValidator.validate('#addFrom')){ .... } }
一旦当asyncAccountName()通过一次,再次提交就不会验证了
I am a beginner of the web technology and I would like to know about how to verify if the password and repeat password from two individual input text box.
<label>Password</label>
<input type="password" name="password" class="form-control" >
<br>
<label>Repeat Password</label>
<input type="password" name="repeatpassword" class="form-control" >
so for this 2 input, how can I verifiy the input values from both inputs and return true once they are having the same values.
Thanks so much!
1、html规则failHtml使用样式,无法使用分号分割样式
2、input获得焦点时没清除失败样式(考虑是否需要这种交互)
3、required的提示不能针对单个input个性化,把required规则改为可覆盖或者requiredMessage作为field选项
4、required规则放在后面时不生效
5、多个input想共用一个消息容器的场景中只会显示最后一个错误消息,但所有的input都应用了fail样式,添加或功能,只在上一个input通过后才验证下一个
6、去掉requiredMessage和noServerMessage,改required和server为全局配置属性,当值为字符串时表示验证失败时提示的文本,修改配置设置局部属性的方式,因为现在无法设置为false的值
看了你的插件很好用,但是有一点,如何在不采用表单submit属性验证提交表单,而是手动验证的方式,我这边采用SMValidator.validate()的方式,发现每次都是true,应该怎么配置?谢谢作者解答
怎么判断验证是否成功,就是我提交表单不用submit,我用其他按钮怎么判断验证是否成功
应该是range?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.