1/*global jQuery:false */ 2jQuery(document).ready(function($) { 3"use strict"; 4 5 //Contact 6 $('form.validateform').submit(function(){ 7 8 var f = $(this).find('.field'), 9 ferror = false, 10 emailExp = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i; 11 12 f.children('input').each(function(){ // run all inputs 13 14 var i = $(this); // current input 15 var rule = i.attr('data-rule'); 16 17 if( rule != undefined ){ 18 var ierror=false; // error flag for current input 19 var pos = rule.indexOf( ':', 0 ); 20 if( pos >= 0 ){ 21 var exp = rule.substr( pos+1, rule.length ); 22 rule = rule.substr(0, pos); 23 }else{ 24 rule = rule.substr( pos+1, rule.length ); 25 } 26 27 switch( rule ){ 28 case 'required': 29 if( i.val()=='' ){ ferror=ierror=true; } 30 break; 31 32 case 'maxlen': 33 if( i.val().length<parseInt(exp) ){ ferror=ierror=true; } 34 break; 35 36 case 'email': 37 if( !emailExp.test(i.val()) ){ ferror=ierror=true; } 38 break; 39 40 41 case 'checked': 42 if( !i.attr('checked') ){ ferror=ierror=true; } 43 break; 44 45 case 'regexp': 46 exp = new RegExp(exp); 47 if( !exp.test(i.val()) ){ ferror=ierror=true; } 48 break; 49 } 50 i.next('.validation').html( ( ierror ? (i.attr('data-msg') != undefined ? i.attr('data-msg') : 'wrong Input') : '' ) ).show('blind'); 51 } 52 }); 53 f.children('textarea').each(function(){ // run all inputs 54 55 var i = $(this); // current input 56 var rule = i.attr('data-rule'); 57 58 if( rule != undefined ){ 59 var ierror=false; // error flag for current input 60 var pos = rule.indexOf( ':', 0 ); 61 if( pos >= 0 ){ 62 var exp = rule.substr( pos+1, rule.length ); 63 rule = rule.substr(0, pos); 64 }else{ 65 rule = rule.substr( pos+1, rule.length ); 66 } 67 68 switch( rule ){ 69 case 'required': 70 if( i.val()=='' ){ ferror=ierror=true; } 71 break; 72 73 case 'maxlen': 74 if( i.val().length<parseInt(exp) ){ ferror=ierror=true; } 75 break; 76 } 77 i.next('.validation').html( ( ierror ? (i.attr('data-msg') != undefined ? i.attr('data-msg') : 'wrong Input') : '' ) ).show('blind'); 78 } 79 }); 80 if( ferror ) return false; 81 else var str = $(this).serialize(); 82 83 $.ajax({
84 type: "POST", 85 url: "contact/contact_prd.php", 86 data: str, 87 success: function(msg){ 88 $("#sendmessage").addClass("show"); 89 $("#errormessage").ajaxComplete(function(event, request, settings){ 90 91 if(msg == 'OK') 92 { 93 $("#sendmessage").addClass("show"); 94 95 } 96 else 97 { 98 $("#sendmessage").removeClass("show"); 99 result = msg; 100 } 101 102 $(this).html(result);});}}); 103 return false; 104 }); 105 106});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.