javascript - Check value of starting characters of an input Jquery -



javascript - Check value of starting characters of an input Jquery -

i have text field can take input of kind. based on input, need create fields hidden , others unhidden. want set status within first status check first 3 characters of input value

here code first condition:

$("#accountcodes").live("focusout",function(){ var code = $(this).val(); if(code>30000){ alert("t1 t4 codes needed"); $(this).parents("tr").find('#t1').removeattr('hidden','hidden'); $(this).parents("tr").find('#t2').removeattr('hidden','hidden'); $(this).parents("tr").find('#t3').removeattr('hidden','hidden'); $(this).parents("tr").find('#t4').removeattr('hidden','hidden'); } })

i want set status within if statement(if within if) check if first 3 characters start 310 or 311 else e.g if user inputs 31102, field unhidden e.t.c not sure how in jquery. should utilize regex? take value of input , cutting out first 3 characters , check it? help appreciated

so want know substr()? code.substr(0,3) first 3 characters.

alternatively, may want utilize regex find 310 , 311 more easily, in case want code.match(/^31[01]/) instead.

javascript jquery html

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -