AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Delphi and Text input

Ein Thema von drama22 · begonnen am 31. Okt 2014 · letzter Beitrag vom 31. Okt 2014
Antwort Antwort
drama22

Registriert seit: 12. Jan 2013
88 Beiträge
 
#1

Delphi and Text input

  Alt 31. Okt 2014, 21:53
hi, regarding my previews post iam trying to submit youtube links to other form i done with every thing but one thing has left ,, i want to allow only youtube links to be sent like only youtube links can be submitted i try method to force the text input to have more than 33 chars like this

Delphi-Quellcode:
begin
  if Length(Trim(Textinput.Text)) < 33 then
  begin
Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end
basically this well force to insert text longer than 33 length but thats not the goal ,, is there any function to check if there is youtube url or not ?
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: Delphi and Text input

  Alt 31. Okt 2014, 22:03
Maybe if the text starts with
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
drama22

Registriert seit: 12. Jan 2013
88 Beiträge
 
#3

AW: Delphi and Text input

  Alt 31. Okt 2014, 22:07
Maybe if the text starts with
i think about that but iam stuck with coding i try somthing like that

Delphi-Quellcode:
if Length(Trim(textinput.Text)) < 33 then
  begin
Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end else
  if AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end
but i got Thats not youtube link all the way cant send

Geändert von drama22 (31. Okt 2014 um 22:22 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#4

AW: Delphi and Text input

  Alt 31. Okt 2014, 22:23
  1. check if the string starts with http:// and remove it (temporary variable)
  2. get all characters from the temporary variable until the first / and check if that is equal to youtube.com or ends with .youtube.com
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)

Geändert von Sir Rufo (31. Okt 2014 um 22:26 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#5

AW: Delphi and Text input

  Alt 31. Okt 2014, 22:30
Delphi-Quellcode:
if Length(Trim(textinput.Text)) < 33 then
  begin
Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end else
  if AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end
but i got Thats not youtube link all the way cant send
Well if the string starts with http://youtube.com , why do you show the message? Show the message if it NOT starts with. Simple logic
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
drama22

Registriert seit: 12. Jan 2013
88 Beiträge
 
#6

AW: Delphi and Text input

  Alt 31. Okt 2014, 22:41
Delphi-Quellcode:
if Length(Trim(textinput.Text)) < 33 then
  begin
Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end else
  if AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end
but i got Thats not youtube link all the way cant send
Well if the string starts with http://youtube.com , why do you show the message? Show the message if it NOT starts with. Simple logic

here is full code

Delphi-Quellcode:
procedure mainform.buttonclick(Sender: TObject);
begin
  if Length(Trim(textinput.Text)) < 33 then
  begin
Application.MessageBox('invalid Youtube link', 'Info!', mb_iconWarning);
  end else
  if not AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end else
  begin
MessageDlg('done', mtInformation, [mbOK],0);
close;
  end;
end;
but always get Thats not youtube link
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#7

AW: Delphi and Text input

  Alt 31. Okt 2014, 22:47
Sorry to hear that but I think your delphi is broken.

if this
Delphi-Quellcode:
if not AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end;
and that
Delphi-Quellcode:
if AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end;
Always shows the "Thats not youtube link" message, then your delphi must be broken.
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
drama22

Registriert seit: 12. Jan 2013
88 Beiträge
 
#8

AW: Delphi and Text input

  Alt 31. Okt 2014, 22:51
Sorry to hear that but I think your delphi is broken.

if this
Delphi-Quellcode:
if not AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end;
and that
Delphi-Quellcode:
if AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end;
Always shows the "Thats not youtube link" message, then your delphi must be broken.
my delphi version is broken ? or the unit of System.StrUtils ?
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:03 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz