Forum Moderators: open

Message Too Old, No Replies

simple but urgent need

User should not enter http:// only enter www check

         

AjiNIMC

5:23 am on Feb 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

Urgent need, How will check that user should not enter any http or :// they should enter only www.webmasterworld.com. How can check using a js.

Thanks and a quick reply will be highly appreciated.

Aji

isitreal

7:16 pm on Feb 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You need to add form validation, like this (comment out the alert after you're sure it works), this version would check for several possible spellings of [,...] you could obviously add as many as you wanted:

<script type="text/javascript" src="">
function checkurl()
{
url=document.frm1.url;
if ( ( url.value.indexOf('http://')== 0 ) )
{
url = url.value.substr( 7 );
}
else if ( ( url.value.indexOf('http:/')== 0 ) )
{
url = url.value.substr( 6 );
}
else if ( ( url.value.indexOf('http:')== 0 ) )
{
url = url.value.substr( 5 );
}
else if ( ( url.value.indexOf('http')== 0 ) )
{
url = url.value.substr( 4 );
}
else if ( ( url.value.indexOf('://')== 0 ) )
{
url = url.value.substr( 3 );
}
else
{
url = url.value;
}
alert (url);
return true;
}
</script>
<form onsubmit="checkurl();" name="frm1">
<input type="text" maxlength="40" size="30" name="url" />
<input type="submit" value="submit url" />
</form>

AjiNIMC

9:53 am on Feb 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have done a character check for / \ : , e.t.c and now it is working fine, you can have a look. If you think I am missing something do inform me. (www).(getcrm.com/signup/).I think its working fine.

But thanks for the reply I will keep this as well.

Aji

AjiNIMC

9:57 am on Feb 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Now I want something else. On click of a radio button(say radio 1) only two rows of table1 should be displayed. And when I click on the next radio button(radio 2), the three rows of table 1 should be shown.

This is an easy one and I have done it a long back, now donot remember the way, I am trying. Please help and a fast help will give me a fast relieve.

Thanks once again
Aji

isitreal

10:33 pm on Feb 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you don't want to check for just / because that could be part of a web address, mysite/main/index.htm.

Purple Martin

11:45 pm on Feb 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using JavaScript for form validation (as you are doing) is a good thing to do, because it ensures that most people enter the correct information before submitting the form. But it doesn't ensure that all people get it right, because some people have JavaScript turned off. Therefore you must ALWAYS perform a server-side validation check as well, using a server-side language such as php/asp/jsp etc.

AjiNIMC

3:57 am on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>you don't want to check for just / because ..

No we donot allow for anything else than www.xyz.com no other pages permitted. Yeah I know there are few guys who turn JS off, Thanks,I will do a php on server side for that as well.

Now another problem please solve it as it is giving me a high time trouble. I am not able to do it.

The problem

I have three rows in a table and two option(Radio button) Admin1 and Admin 2.
row 1) Enter Name
row 2) Enter URL
row 3) Enter Password.

Now here, when I click admin 1, row 1) and row 3) should displayed. When click admin 2, row 2 and row 3) should display. This part is done using div for each content inside each cell.

How can do it for a complete row.I mean just hide one row and allow other.

Please Help.

Thanks
Aji

Purple Martin

4:13 am on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I guess you could give the row tags unique ids and then rewrite their contents by changing their innerHTML properties. Rows with no content will automatically collapse and disappear. Or just rewrite the entire table in the same way. Or... I like this better... have only two rows, and rewrite the contents of the second row to be one thing or another. Or instead or rewriting stuff, use the visibility property to make unwanted stuff hidden.

AjiNIMC

4:57 am on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have tried with the rows and tables but it did nto work. Can someone try it and give a hint of code. That will be highly appreciated, ot otherwise I will use farmes for both the radio button(will I will do as the last move).

thanks
Aji

Purple Martin

5:21 am on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hint of code:

<tr id="row2"><td>URL</td></tr>

document.getElementById("row2").innerHTML = "<td>Password</td>"

(Disclaimer - I've used innerHTML many times, but never to rewrite table cells. I've no idea how the browser's rendering engine will cope with changing table content since tables are rendered all-at-once after all the sizing calculations are complete.)