By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

Regular Expression with Javascript

P: 32
Hi all,
I having a string like this

[PHP]<INPUT onkeypress=ValidateTime() id=t2_2 onblur=validateBtime(document.Baco.t2_2) style="WIDTH: 50px\" maxLength=5 value=20:00 > [/PHP]

Now I want to replace the

[PHP]value=20:00[/PHP]

with another value. How can I do this using Javascript.

Thanks
Dana
Feb 4 '08 #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,333
hi ...

first your atttribute-values should be enclosed in double quotes (see string s) ... then have a look at the example:

Expand|Select|Wrap|Line Numbers
  1. var s = '<INPUT onkeypress="ValidateTime()" id="t2_2" onblur="validateBtime(document.Baco.t2_2)" style="WIDTH: 50px" maxLength="5" value="20:00" >';
  2.  
  3. s = s.replace(/value=".{5}"/, 'value="test"');
  4.  
  5. alert(s);
  6.  
kind regards
Feb 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.