Forum Moderators: open

Message Too Old, No Replies

toggle display

with a regexp

         

stef25

4:32 pm on Apr 9, 2006 (gmt 0)

10+ Year Member



im using a regular expression to validate a text field. instead of throwing an alert, id like to make a <div> that contains an error message display:block (default is none;)

im able to make the div display:block by clicking a link. onclick calls a function and passes 'block' to it

however im at a loss as to how i can pass 'block' to this function as a result of a non match coming from the regular expression ...?

im using

function changeViz(newViz) {
if (document.getElementById) {
var div = document.getElementById('the_div');
div.style.display = newViz;
}

else {
alert("Sorry, you need a newer browser.");
}
}

phillipandrews

2:07 am on Apr 10, 2006 (gmt 0)

10+ Year Member



Try this:
function TestStuff(str) {
var myRegExp=/whatever/;
unless myRegExp.test(str) {
changeViz('block');
}
}
... if newViz is the new text... i've never seen the style.display property used before