validators.js 893 B

123456789101112131415161718192021222324252627282930313233
  1. /*App.Validate.form = function(values){
  2. if(values.IP_ADDRESS == '') {
  3. return alert('Not correct ip');
  4. }
  5. return true;
  6. }*/
  7. App.Validate.Is = {
  8. ip: function(object) {
  9. var ip_regexp = new RegExp(/\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/);
  10. return ip_regexp.test() ? false : App.i18n.getMessage('incorrect_ip');
  11. }
  12. };
  13. App.Validate.form = function(values, form_ref){
  14. // TODO: validate it!
  15. return true;
  16. var errors = [];
  17. $.each(values, function(key) {
  18. var value = values[key];
  19. /*if ('undefined' != typeof App.Validate.Is[key] ) {
  20. if(var error = App.Validate.Is[key](value)) {
  21. errors[erros.length++] = error;
  22. }
  23. }*/
  24. });
  25. }