javascript - split string doesn't work -


for form validation wrote function split date in 3 pieces. pieces split "\"

so date looks "01\01\2013"

here's function

function check_date() {                      var input = $('#start_date').val();                     var lines = input.split('\\');                     if (lines[0] <= 31) {                         $('#start_date').css({'border': '1px solid #b0b0b0'});                     } else {                         $('#start_date').css({'border': '1px solid red'});                     }                      if (lines[1] <= 12) {                         $('#start_date').css({'border': '1px solid #b0b0b0'});                     } else {                         $('#start_date').css({'border': '1px solid red'});                     }                  } 

but doesn't work @ all...

is there can help?

thx :)

you're splitting \\ date split /.

do mean input.split('/');?

\\ equal literal backslash character, work fine if date 01\01\2013.

you \\ works fine?

var input = '01\\01\\2013'; var lines = input.split('\\');  if (lines[0] <= 31) {     console.log('lines[0] ok'); //it reaches } else {     console.log('lines[0] not ok'); }  if (lines[1] <= 12) {     console.log('lines[1] ok'); //it reaches } else {     console.log('lines[1] not ok'); } 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -