javascript - Java Script Invalid Date -
i using jquery datepicker dates. once dates saved db shows on screen; send load time date new date(), shows "invalid format".
how can fix it?
<input class="edittxtfrmt doj valid" `type="text" style="width:100%;"> var txt = name.replace("releavingdt","doj"); joindt = $("input[name='"+txt+"']").val(); new date(joindt)
i don't know wrong code, go line line , point out issues:
<input class="edittxtfrmt doj valid" `type="text" style="width:100%;"> there backtick right before type="text". remove it!
var txt = name.replace("releavingdt","doj"); what value of name? coming from?
joindt = $("input[name='"+txt+"']").val(); you looking input element has name attribute of whatever txt is. if valid string out of txt (which doubt looking @ line above), sample input element above, doesn't have name attribute. joindt undefined
new date(joindt) this line correct, if joindt valid. however, given issues above, believe joindt undefined @ point.
how debug:
change code , let know alerts giving you:
html:
<input class="edittxtfrmt doj valid" type="text" style="width:100%;"> js:
alert("name is: "+name); var txt = name.replace("releavingdt","doj"); alert("txt is: "+txt); joindt = $("input[name='"+txt+"']").val(); alert("joindt is: "+joindt); new date(joindt)
Comments
Post a Comment