validation mixin small fixes
This commit is contained in:
@@ -91,17 +91,32 @@ var Register = React.createClass({
|
||||
},
|
||||
validations: {
|
||||
firstName: function(value) {
|
||||
var errors = [];
|
||||
if (!value || value === '') {
|
||||
errors.push("Ime je obavezno.");
|
||||
return ["Ime je obavezno."];
|
||||
}
|
||||
},
|
||||
password: function(value, callback) {
|
||||
if(value === undefined || value === "") {
|
||||
return ["Šifra je obavezna."];
|
||||
}
|
||||
|
||||
if (value.length < 6) {
|
||||
return ["Šifra mora sadržavati minimalno 6 karaktera."]
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback([], ["passwordConfirmation"]);
|
||||
}
|
||||
},
|
||||
passwordConfirmation: function(value) {
|
||||
if (this.getState().password !== value) {
|
||||
return ["Šifre se ne podudaraju."];
|
||||
}
|
||||
return errors;
|
||||
},
|
||||
lastName : function(value) {
|
||||
if (value === 'Dazdarevic') {
|
||||
return ["You're the owner!"];
|
||||
if (!value || value === '') {
|
||||
return ["Prezime je obavezno."];
|
||||
}
|
||||
return [];
|
||||
},
|
||||
_emailRe: /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
||||
_emailTimeoutId: null,
|
||||
@@ -125,6 +140,7 @@ var Register = React.createClass({
|
||||
//}
|
||||
|
||||
//}.bind(this), 1000);
|
||||
|
||||
} else {
|
||||
return ['Neispravna email adresa.'];
|
||||
}
|
||||
@@ -196,13 +212,17 @@ var Register = React.createClass({
|
||||
<div className="form-group">
|
||||
<label for="password" className="col-md-4 control-label">Šifra</label>
|
||||
<div className="col-md-4">
|
||||
<input type="password" valueLink={this.linkState('password')} className="form-control" id="password" placeholder="Šifra"/>
|
||||
<input type="password" onChange={this.handleChange('password')} className="form-control" id="password" placeholder="Šifra"/>
|
||||
{this.getValidationMessages('password').map(this.renderErrorMessage)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label for="password_confirmation" className="col-md-4 control-label">Potvrda šifre</label>
|
||||
<div className="col-md-4">
|
||||
<input type="password" valueLink={this.linkState('passwordConfirmation')} className="form-control" id="password_confirmation" placeholder="Podvrda šifre"/>
|
||||
<input type="password" onChange={this.handleChange('passwordConfirmation')} className="form-control" id="password_confirmation" placeholder="Podvrda šifre"/>
|
||||
|
||||
|
||||
{this.getValidationMessages('passwordConfirmation').map(this.renderErrorMessage)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -218,7 +238,10 @@ var Register = React.createClass({
|
||||
|
||||
<div className="form-group">
|
||||
<div className="col-md-4">
|
||||
<button onClick={this.doRegister}>Save</button>
|
||||
|
||||
<button onClick={this.doRegister} type="button" className="btn btn-default btn-lg">
|
||||
Register2
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
Reference in New Issue
Block a user